【问题标题】:Heroku Deployment - Rails 6.1.3 - Bundle install failing - Gemfile.lock platform additionHeroku 部署 - Rails 6.1.3 - 捆绑安装失败 - Gemfile.lock 平台添加
【发布时间】:2021-05-27 09:22:29
【问题描述】:

我正在尝试使用 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.lock 文件,但遇到了这个依赖错误:

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.lock 文件的建议,但这破坏了我的本地服务器,这是有道理的。如有必要,我很乐意提供更多信息。

【问题讨论】:

  • 您的 ruby​​ 版本似乎有错误,请通过将您的 Gemfile 中的 ruby​​ 版本更改为 2.7.2 并安装本地相同版本来检查。
  • 我想我不明白依赖错误信息。这似乎表明我需要一个 >= 2.5 的 ruby​​ 版本,这是满意的吗?
  • 是的,但大于 2.5 将是 2.7.2,因为目前 Rails 不支持 3.0.0,Heroku 也一样。

标签: ruby-on-rails ruby heroku


【解决方案1】:

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

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

参考

https://www.moncefbelyamani.com/understanding-the-gemfile-lock-file/#platforms

https://bundler.io/man/gemfile.5.html#PLATFORMS

https://github.com/rubygems/rubygems/issues/4269#issuecomment-758564690

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-12
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2015-10-19
    相关资源
    最近更新 更多