Deekor
Deekor

Reputation: 9499

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

Upvotes: 1

Views: 331

Answers (2)

Deekor
Deekor

Reputation: 9499

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

Upvotes: 1

tadman
tadman

Reputation: 211720

You may need to force Bundler to manage the dependencies:

bundle exec rails assets:precompile

Where that ensures the Gem environment is locked in as per the Gemfile.

Rails generally tries to get this working for you, but there are occasions when it can't quite get things in sync and the behaviour you're seeing manifests.

Upvotes: 3

Related Questions