Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find 'bundler' (2.1.4) required by your /home/rails/webapp/Gemfile.lock. (Gem::GemNotFoundException) running docker build

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!

like image 904
Salo Charabati Avatar asked Jun 05 '20 04:06

Salo Charabati


People also ask

How do I install gems in Gemfile?

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.

Where are bundler gems installed?

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.


1 Answers

add

RUN gem install bundler

before you invoke bundler, that should do the trick.

like image 101
Mr. Avatar answered Nov 15 '22 17:11

Mr.