【问题标题】:! Failed to install gems via Bundler Heroku Rails!无法通过 Bundler Heroku Rails 安装 gem
【发布时间】:2021-08-27 16:37:55
【问题描述】:

我是 RoR 的超级新手,正在尝试在 heroku 上部署我的应用程序。我收到了您在标题中看到的错误。

宝石文件:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.0'
gem 'mail_form'
gem 'figaro'
gem 'rails', '~> 6.1.0'
# gem 'sqlite3', '~> 1.4'
gem 'puma', '~> 5.0'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 5.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bootsnap', '>= 1.4.4', require: false
gem 'devise', '~> 4.7', '>= 4.7.3'
gem 'pg'

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'web-console', '>= 4.1.0'
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
  gem 'spring'
end

group :test do
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver'
  gem 'webdrivers'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

堆栈

Enumerating objects: 424, done.
Counting objects: 100% (424/424), done.
Delta compression using up to 8 threads
Compressing objects: 100% (391/391), done.
Writing objects: 100% (424/424), 265.61 KiB | 6.18 MiB/s, done.
Total 424 (delta 193), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-18 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:                         Detected buildpacks: Ruby,Node.js
remote:                         See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.2.16
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.7.0
remote: -----> Installing dependencies using bundler 2.2.16
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote:        Unable to find a spec satisfying nokogiri (>= 1.8.5) in the set. Perhaps the
remote:        lockfile is corrupted? Found nokogiri (1.11.7-x86_64-darwin), nokogiri
remote:        (1.11.7-x86_64-darwin), nokogiri (1.11.7-x86_64-darwin), nokogiri
remote:        (1.11.7-x86_64-darwin), nokogiri (1.11.7-x86_64-darwin) that did not match the
remote:        current platform.
remote:        Bundler Output: Unable to find a spec satisfying nokogiri (>= 1.8.5) in the set. Perhaps the
remote:        lockfile is corrupted? Found nokogiri (1.11.7-x86_64-darwin), nokogiri
remote:        (1.11.7-x86_64-darwin), nokogiri (1.11.7-x86_64-darwin), nokogiri
remote:        (1.11.7-x86_64-darwin), nokogiri (1.11.7-x86_64-darwin) that did not match the
remote:        current platform.
remote: 
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 

我已经解决了之前的所有问题并尝试了所有解决方案。 我已经尝试删除 gemfile.lock 并再次运行 bundle install 来重置它。我已经完成了各种 git add、提交和推送。我有点不知道从这里去哪里。任何建议将不胜感激。

【问题讨论】:

    标签: ruby-on-rails ruby heroku


    【解决方案1】:

    nokogiri (1.11.7-x86_64-darwin)Darwin/MacOS 的原生 gem,但 Heroku 运行 Linux 以便它 unable to find

    解决方案是avoid-using-a-precompiled-native-gem,在您的情况下,bundler 版本 2.2.+,然后您需要运行 bundle config set force_ruby_platform true

    你应该重新检查Gemfile.lock不包含nokogiri (1.11.7-x86_64-darwin),它应该包含nokogiri (~> ...)

    【讨论】:

    • 谢谢你,Lam,我运行了你的命令并检查了 nokogiri Gem 的 gemfile.lock,但它不存在。不幸的是,我仍然无法部署到 Heroku
    • 是的,还是一样。我最终将 gem "nokogiri", ">= 1.11.7" 添加到我的 gemfile 并运行包。这解决了他们的问题!谢谢你的帮助林!
    【解决方案2】:

    我在 M1 Macbook 上遇到了同样的问题。我删除了Gemfile.lock,然后运行 ​​bundle install 重新构建了Gemfile.lock,这修复了上述错误。

    【讨论】:

      猜你喜欢
      • 2019-01-07
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-26
      • 1970-01-01
      • 2011-06-02
      相关资源
      最近更新 更多