【问题标题】:Heroku installs Bundler then throws error Bundler 2.0.1Heroku 安装 Bundler 然后抛出错误 Bundler 2.0.1
【发布时间】:2019-06-20 06:19:44
【问题描述】:

我正在尝试将 Rails 应用程序部署到 Heroku。自从我在那里部署任何东西已经有一段时间了,但我对这里发生的事情一无所知。

这是一个相当基本的 Rails 5 应用程序。部署顺利通过 Gemfile,然后失败并出现错误,要求我安装 Bundler v 2.0.1。这是日志的有趣部分:

remote:        Fetching devise 4.6.2
remote:        Installing sass-rails 5.0.7
remote:        Installing devise 4.6.2
remote:        Bundle complete! 26 Gemfile dependencies, 78 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Post-install message from i18n:
remote:        
remote:        HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
remote:        But that may break your application.
remote:        
remote:        Please check your Rails app for 'config.i18n.fallbacks = true'.
remote:        If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
remote:        'config.i18n.fallbacks = [I18n.default_locale]'.
remote:        If not, fallbacks will be broken in your app by I18n 1.1.x.
remote:        
remote:        For more info see:
remote:        https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
remote:        
remote:        Post-install message from sass:
remote:        
remote:        Ruby Sass has reached end-of-life and should no longer be used.
remote:        
remote:        * If you use Sass as a command-line tool, we recommend using Dart Sass, the new
remote:          primary implementation: https://sass-lang.com/install
remote:        
remote:        * If you use Sass as a plug-in for a Ruby web framework, we recommend using the
remote:          sassc gem: https://github.com/sass/sassc-ruby#readme
remote:        
remote:        * For more details, please refer to the Sass blog:
remote:          https://sass-lang.com/blog/posts/7828841
remote:        
remote:        Removing bundler (2.0.1)
remote:        Bundle completed (47.21s)
remote:        Cleaning up the bundler cache.
remote: -----> Installing node-v10.14.1-linux-x64
remote:        Detected manifest file, assuming assets were compiled locally
remote: -----> Detecting rails configuration
remote: -----> Detecting rake tasks
remote: 
remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     Activating bundler (2.0.1) failed:
remote:  !     Could not find 'bundler' (2.0.1) required by your /tmp/build_94d6a4f5d4fbb862672998d5d06d2506/Gemfile.lock.
remote:  !     To update to the latest version installed on your system, run `bundle update --bundler`.
remote:  !     To install the missing version, run `gem install bundler:2.0.1`
remote:  !     Checked in 'GEM_PATH=/tmp/build_94d6a4f5d4fbb862672998d5d06d2506/vendor/bundle/ruby/2.7.0', execute `gem env` for more information
remote:  !     
remote:  !     To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
remote:  !
remote: /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/rake_runner.rb:106:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
remote: ensure you can run `$ bundle exec rake -P` against your app
remote: and using the production group of your Gemfile.
remote: Activating bundler (2.0.1) failed:
remote: Could not find 'bundler' (2.0.1) required by your /tmp/build_94d6a4f5d4fbb862672998d5d06d2506/Gemfile.lock.
remote: To update to the latest version installed on your system, run `bundle update --bundler`.
remote: To install the missing version, run `gem install bundler:2.0.1`
remote: Checked in 'GEM_PATH=/tmp/build_94d6a4f5d4fbb862672998d5d06d2506/vendor/bundle/ruby/2.7.0', execute `gem env` for more information
remote: 
remote: To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`

我不明白发生了什么,因为 Heroku 似乎在部署中运行得很好,然后删除了 bundler,然后在 rake 任务上抛出错误并再次要求 bundler。我已经执行了RAILS_ENV=production bundle exec rake assets:precompile,并且它显示为最新的。我一定在这里遗漏了一些东西,希望最近有 Heroku 经验的人能指出这一点。

编辑 我也运行了bundle exec rake -P 命令,没有失败

【问题讨论】:

  • 您是否尝试将bundler 添加到您的Gemfile
  • 我有。有版本号和没有版本号,生产组内外都有

标签: heroku ruby-on-rails-5 bundler


【解决方案1】:

很可能,您只需运行即可解决此问题

gem install bundler -v 2.0.2
bundle update --bundler

提交它在您的 Gemfile.lock 中所做的更改,然后您的下一次 Heroku 推送将顺利通过。

【讨论】:

  • 我更新时错过了运行第二个命令 - 这解决了它。谢谢!
  • 这对我有用,应该是第一个尝试的。
【解决方案2】:

我通过升级到 Ruby 2.6.3 和 Bundler 2.0.2 修复了我们在 Heroku 上的构建。

我们在 Heroku 上的构建在过去几天开始出现类似的错误消息:

Could not find 'bundler' (2.0.1) required by your ... Gemfile.lock.

我们在本地构建的 Ruby 2.6.1 和 Bundler 2.0.1 上运行良好。直到几天前,这个组合在 Heroku 上也运行良好。

在查探 Heroku 文档时,我注意到了 Dev Center article,它于 2019 年 6 月 26 日更新。它指出:

捆绑器 2.0.2 请参阅 2.0.1 的问题。

许多人遇到了问题 4,该问题仅在发布新的 Bundler 版本时触发。这是由于 Rubygems 中的一个错误而发生的,可以通过升级到 2.5.5+ 或 2.6.3+ 来修复。

2.0.1 状态下的问题 4:

[您可能会收到错误] 由于 Rubygems 捆绑器版本检查代码中的错误。为避免此问题,请升级您的 Ruby 版本。它在 2.5.5+ 和 2.6.3+ 中修复。如果您不更新,您的 Ruby 版本以及 Bundler 2.x 的每个新版本都会触发此问题。

Bundler 2.0.2 于 2019 年 6 月 13 日发布,看来 Heroku 已经开始使用它了。

我注意到您在日志中使用的是 Ruby 2.7。我建议在您的 Gemfile 中指定 ruby '2.6.3',安装 Bundler 2.0.2,并使用该组合捆绑/生成您的 Gemfile.lock。然后,您应该会在锁定文件的底部看到这一点,并希望您的应用在 Heroku 上成功构建:

RUBY VERSION
   ruby 2.6.3p62

BUNDLED WITH
   2.0.2

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-01
    • 1970-01-01
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 2011-10-27
    • 2013-05-22
    相关资源
    最近更新 更多