ruby-on-rails - 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
我尝试了几种解决方案,例如:
运行
RAILS_ENV=production bundle exec rake assets:precompile
(见这里)添加
RAILS_SERVE_STATIC_FILES
密钥(相同)将 Ruby 升级到 2.6.3(请参阅此处,找不到带有 rbenv 和 rvm 的 2.6.3)
我相信这可能是由于这个问题。我担心这一点吗?
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
和以下行
解决方案
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
,提交更改并重新部署。Gemfile
bundle install
推荐阅读
- reactjs - 按钮多行版式
- raspberry-pi - 在 armhf 中没有实现 __fpclassify
- python - 非线性方程组
- c# - 使用 NodaTime LocalDate 调用 Web api POST (abp appservice) 无法序列化
- javascript - Parcel js 无法在 Ubuntu 上运行相同的项目
- ethereum - 无法使用 Minty 部署
- time-series - Thingsboard - 在小部件中的两个变量之间划分
- azure - 无法使用公共 IP 访问 Azure VM 中的 Docker 容器
- firebase - 如何允许用户在 Firebase 身份验证中更改错误的电子邮件地址
- python - Django 中的 VSCode 调试器仅在功能视图上写出“断点()”时停止