首页 > 解决方案 > Ruby 2.6.1 和 Bundler 2.0.1 到 Heroku:我应该写一个 Procfile 吗?

问题描述

在尝试将应用程序部署到 Heroku 时,我遇到了无法处理的错误(这是我的第一次)。

# ERROR when I try to `git push heroku master`
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_e569680f858939ef8f1f8ef3e8902eff/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_e569680f858939ef8f1f8ef3e8902eff/vendor/bundle/ruby/2.6.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 buildpacks
=== staging-det-music Buildpack URLs
1. heroku/nodejs
2. heroku/ruby
# Gemfile.lock
RUBY VERSION
   ruby 2.6.1p33

BUNDLED WITH
   2.0.1

我尝试了几种解决方案,例如:

我相信这可能是由于这个问题。我担心这一点吗?

2) 当使用 binstubs 运行命令而不是 bundle exec 时,使用 Ruby 2.6.x 时可能会激活错误版本的 Bundler。此错误已报告给 Ruby Core,并将在 Ruby 2.6.3 发布时修复。

短期内,解决方法是确保 Procfile 和 app.json 中的所有命令都以 bundle exec 开头。例如:

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

worker: bundle exec sidekiq -C config/sidekiq.yml

作为一个新手,我真的很迷茫,有人可以帮助我吗?

谢谢你的时间

解决方案:在Gemfile.lock中找到删除BUNDLED WITH和以下行

标签: ruby-on-railsrubyherokurakebundler

解决方案


Heroku 上的 Bundler 2存在已知问题,包括以下问题:

指定 bundler 2.0.2 的 Gemfile.lock 不适用于 bundler 2.0.1

如果您尝试将使用 bundler 2.0.2 的应用程序部署到使用 bundler 2.0.1 的 Heroku 平台上,您可能会收到以下错误:

`find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

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

在本地将 Ruby 升级到至少 2.6.3 版,更新您的 , 中的版本ruby,提交更改并重新部署。Gemfilebundle install


推荐阅读