Search code examples
rubydockerrubygemsbundler

The git source is not yet checked out when running Docker


I'm currently facing an error when trying to use a gem from GitHub. I have the following in my Gemfile:

# Gemfile
source 'https://rubygems.org'
ruby '2.3.1'

gem 'sinatra'
gem 'rack'
gem 'puma'

group :development do
  gem 'byebug'
  gem 'rack-test'
  gem 'rerun', github: 'alexch/rerun', branch: 'master'
end

When I run bundle install from Dockerfile it works with a message like:

...
Installing sinatra 1.4.6
Installing listen 3.1.5 (was 3.0.6)
Using rerun 0.11.0 from git://github.com/alexch/rerun.git (at master@3e4c486)
Bundle complete! 6 Gemfile dependencies, 14 gems now installed.
...

However, when I go to start the container I get:

The git source git://github.com/alexch/rerun.git is not yet checked out. Please run `bundle install` before trying to start your application

I've seen similar issues but not related to Docker.


Solution

  • Turns out I was able to find the issue. The problem was related to my Gemfile being used to build the Docker image.

    I had not locally run a bundle install command which led to the Gemfile.lock not being updated. Once I ran the command the following was added to my Gemfile.lock:

    @@ -1,14 +1,20 @@
    +GIT
    +  remote: git://github.com/alexch/rerun.git
    +  revision: 3e4c486304be406cb86180ef70ec24e9ae055ce4
    +  branch: master
    +  specs:
    +    rerun (0.11.0)
    +      listen (~> 3.0)
    

    Turns out that was all I needed. Once I had the updated file, rebuilt the image and ran the container everything worked as expected with bundle exec rerun. So the catch was that I was using the Gemfile.lock to help with caching / version locking but failed to keep it updated with my Gemfile.