【问题标题】:Heroku deploy Ruby 2.6.1 : warn_for_outdated_bundler_versionHeroku 部署 Ruby 2.6.1:warn_for_outdated_bundler_version
【发布时间】:2019-08-12 03:17:42
【问题描述】:

这个问题与this one 有关,但建议的解决方案对我不起作用。

我正在尝试使用Ruby 2.6.1 部署Rails 5.2 应用程序,但在部署阶段我不断收到此错误:

/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/lockfile_parser.rb:95:in `initialize'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/definition.rb:83:in `new'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/definition.rb:83:in `initialize'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/dsl.rb:234:in `new'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/dsl.rb:234:in `to_definition'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/dsl.rb:13:in `evaluate'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/definition.rb:34:in `build'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler.rb:135:in `definition'
from /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler.rb:101:in `setup'
from /app/vendor/ruby-2.6.1/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'
from /app/vendor/ruby-2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /app/vendor/ruby-2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /app/config/boot.rb:3:in `<top (required)>'
from /app/bin/rake:2:in `require_relative'
from /app/bin/rake:2:in `<main>'

我在这个错误中发现奇怪的是这一行:

/app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.1/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)

Heroku 似乎说它正在使用Ruby 2.6.0。但在构建阶段,它说它使用Ruby 2.6.1 和Bundler 2:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.1
-----> Installing dependencies using bundler 2.0.1

构建成功,但部署失败。

这是我的应用程序的配置方式。

Gemfile(简化为重要的)

ruby "2.6.1"
gem 'rails', '~> 5.2'

Gemfile.lock(简化为重要的)

RUBY VERSION
   ruby 2.6.1p33

BUNDLED WITH
   2.0.1

在 heroku 上,我的 buildpack 是 heroku/ruby。我的堆栈是heroku-18。

Heroku 似乎支持Bundler 2,如this post 所述。

知道部署中可能会失败的原因吗?

【问题讨论】:

    标签: ruby-on-rails heroku bundler


    【解决方案1】:

    我找到了解决方案。问题出在部署时,而不是在构建期间。部署使用的是 Ruby 2.6.0,因为 Heroku 的 web dyno 默认是:

    rails server -p $PORT -e $RAILS_ENV
    

    然而,this post from bundler github 告诉在每个命令前加上 bundle exec。但是来自测功机的rails server 命令没有前缀。

    我发现的一种解决方法是修改项目Procfile 文件,并添加以下行:

    web: bundle exec rails server -p $PORT -e $RAILS_ENV
    

    这样,rails server 命令使用预期的Ruby version,2.6.1,而不是产生错误的2.6.0。

    【讨论】:

      猜你喜欢
      • 2017-08-28
      • 2013-05-25
      • 2023-03-31
      • 2012-05-23
      • 2019-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多