Search code examples
ruby-on-railsrubydockerdockerfilebundler

Rails assets:precompile is using wrong bundler version


I recently updated my dockerized rails app (5.0 -> 5.2) and am now using Bundler 2.

I've added RUN gem install bundler to my Dockerfile to ensure I have Bundler 2 installed. My RUN bundle install step runs fine, but when I get to the asset precompile step it seems to start using Bundler 1 again:

Step 12/17 : RUN rails assets:precompile --trace
 ---> Running in facccf7d562c
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.14.6/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)

1. Why is the asset precompile even using bundler?

2. How can I force it to user Bundler 2?

Here is the snippet of my Dockerfile that fails (on the last step):

RUN gem install bundler

RUN bundle install
RUN yarn install
RUN rails assets:precompile --trace

Solution

  • Seems to have been a bug in Ruby 2.4.0 upgrading to 2.4.5 fixed this issue.