简体   繁体   English

Rails资产:预编译使用了错误的捆绑程序版本

[英]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. 我最近更新了我的dockerized rails应用程序(5.0-> 5.2),现在正在使用Bundler 2。

I've added RUN gem install bundler to my Dockerfile to ensure I have Bundler 2 installed. 我已将RUN gem install bundler添加到我的Dockerfile以确保安装了Bundler 2。 My RUN bundle install step runs fine, but when I get to the asset precompile step it seems to start using Bundler 1 again: 我的RUN bundle install步骤运行正常,但是当我进入资产预编译步骤时,它似乎又开始使用Bundler 1:

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? 1.为什么即使使用捆绑器也要对资产进行预编译?

2. How can I force it to user Bundler 2? 2.如何将其强制给Bundler 2用户?

Here is the snippet of my Dockerfile that fails (on the last step): 这是我的Dockerfile失败的代码片段(在最后一步):

RUN gem install bundler

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

You may need to force Bundler to manage the dependencies: 您可能需要强制Bundler管理依赖项:

bundle exec rails assets:precompile

Where that ensures the Gem environment is locked in as per the Gemfile . 确保根据Gemfile锁定Gem环境的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. Rails通常会尝试为您工作,但是有时候它可能无法完全同步事情,并且您看到的行为也很明显。

似乎是Ruby 2.4.0升级到2.4.5的错误,解决了此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM