I've been running into this problem whenever I try to run docker build -t ruby-app .
, I get the following error:
Step 6/8 : RUN bundle install
---> Running in daa149748210
/usr/local/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /home/rails/webapp/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
from /usr/local/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
from /usr/local/bin/bundle:23:in `<main>'
The command '/bin/sh -c bundle install' returned a non-zero code: 1
My Dockerfile is the following:
#Dockerfile
FROM ruby:latest
ENV HOME /home/rails/webapp
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
WORKDIR $HOME
ADD Gemfile* $HOME/
RUN bundle install
ADD . $HOME
CMD ["rails", "server", "--binding", "0.0.0.0"]
My bundler versions installed on my machine are the following:
➜ gem list bundler
*** LOCAL GEMS ***
bundler (2.1.4)
bundler-unload (1.0.2)
rubygems-bundler (1.4.5)
And my Gemfile.lock was generated by the following versions of Ruby and Bundler
#Gemfile.lock
RUBY VERSION
ruby 2.7.0p0
BUNDLED WITH
2.1.4
Any help would be very much appreciated!
run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.
In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them. As a result, bundle install --deployment installs gems to the vendor/bundle directory in the application. This may be overridden using the --path option.
add
RUN gem install bundler
before you invoke bundler
, that should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With