Heroku部署- Rails 6.1.3 - Bundle安装失败- Gemfile.锁平台添加



我正在尝试使用Heroku部署一个简单的Ruby on Rails web应用程序。当我尝试部署web应用程序时,我得到一个捆绑器错误,说正确的平台不在Gemfile.lock

中。下面是构建日志:

-----> Building on the Heroku-20 stack
!     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
Detected buildpacks: Ruby,Node.js
See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Ruby app detected
-----> Installing bundler 2.1.4
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.0.0
-----> Installing dependencies using bundler 2.1.4
Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
Your bundle only supports platforms ["aarch64-linux"] but your local platform is
x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
Bundler Output: Your bundle only supports platforms ["aarch64-linux"] but your local platform is
x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
!
!     Failed to install gems via Bundler.
!
!     Push rejected, failed to compile Ruby app.
!     Push failed

我试图将平台添加到Gemfile。锁定文件,但是出现依赖错误:

matt@matt-desktop:~/projects/auto-bags$ bundle lock --add-platform x86_64-linux
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies.........
Bundler found conflicting requirements for the Ruby version:
In Gemfile:
Ruby (~> 3.0.0.0)
capybara (>= 3.26) was resolved to 3.35.3, which depends on
nokogiri (~> 1.8) was resolved to 1.11.1, which depends on
Ruby (< 3.1.dev, >= 2.5)

我没有找到一个成功的修复在线。有一些删除Gemfile的建议。锁文件,但这破坏了我的本地服务器,这是有道理的。如果需要的话,我很乐意提供更多的信息。

运行以下命令应该可以解决问题。

bundle lock --add-platform x86_64-linux
bundle install
git add . ; git commit -m fix
参考

https://www.moncefbelyamani.com/understanding-the-gemfile-lock-file/平台

https://bundler.io/man/gemfile.5.html平台https://github.com/rubygems/rubygems/issues/4269 issuecomment - 758564690

相关内容