繁体   English   中英

Heroku 推送被拒绝,无法通过 Bundler 安装 gems

[英]Heroku push rejected, failed to install gems via Bundler

我正在努力将我的代码推送到 Heroku。在搜索 Google 和 Stack Overflow 问题后,我一直无法找到解决方案。 这是我尝试“git push heroku master”时得到的结果:

Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
       Installing rails3_serve_static_assets... done
-----> Gemfile detected, running Bundler version 1.0.3
       Unresolved dependencies detected; Installing...
       Fetching source index for http://rubygems.org/
       /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:300:in `open_uri_or_path': bad response Not Found 404 (http://rubygems.org/quick/Marshal.4.8/mail-2.2.6.001.gemspec.rz) (Gem::RemoteFetcher::FetchError)
        from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:172:in `fetch_path'
.
....

最后:

FAILED: http://docs.heroku.com/bundler
 !     Heroku push rejected, failed to install gems via Bundler

error: hooks/pre-receive exited with error code 1
To git@heroku.com:myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:myapp.git'

谢谢你的帮助!

我不认为这是 Rails 版本问题,也不是 Heroku 特有的问题。 (我今天遇到了同样的问题,在我的本地开发机器上运行bundle install时,使用 Rails 3.0.3。)

正如安德鲁建议的那样,在本地运行bundle update解决这个问题。

编辑:正如评论中所建议的:记得git add . , git commit -m "message"

我是这样解决这个问题的:

  1. 捆绑更新
  2. git add Gemfile.lock
  3. git commit -m '为 Heroku 更新 Gemfile.lock'
  4. git push heroku master

我有同样的问题: remote: ! Failed to install gems via Bundler. remote: ! Failed to install gems via Bundler.

如果你看到问题是这样的:

remote:  Your bundle only supports platforms ["x86_64-darwin-16"] but your local platform
remote:  is x86_64-linux. Add the current platform to the lockfile with `bundle  loc
remote:  --add-platform x86_64-linux` and try again.

它的意思是:

Your bundle only supports platforms ["x86_64-darwin-16"] but your local platform is x86_64-linux. Add the current platform to the lockfile with `bundle loc --add-platform x86_64-linux` and try again.

如果你在你的 gemfile.loc 中看到你只有这个:

PLATFORMS
  x86_64-darwin-16

所以我做了这个命令,在 gemfile.loc 中添加你的平台

bundle lock --add-platform x86_64-linux

这将更新您的 Gemfile.loc :

PLATFORMS
  x86_64-darwin-16
  x86_64-linux

继续:

git add .
git commit -m "add platform x86_64-linux"

再推

git push heroku master:main

解决!

bundle lock --add-platform ruby
bundle lock --add-platform x86_64-linux
bundle install
git add .
git commit -m "Bundler fix"

使用:

rm -rf ~/.bundle/ ~/.gem/ .bundle/ Gemfile.lock

我在我的本地Gemfile.lock上有Gemfile.lock确保从本地服务器和 HEROKU V 机器中删除它。

另一个提示:打开你的 Gemfile.lock 并检查这个块是否存在:

PLATFORMS
  x86_64-darwin-20

如果存在,请运行以下命令: bundle config force_ruby_platform true

现在,您必须重新创建整个 Gemfile.lock,因为有些 gem 可以只为 MacOS 构建。 所以,只需删除Gemfile.lock并运行bundle install (不要忘记停止 spring,如果它正在运行,否则 spring 会自动重新创建 Gemfile.lock 文件)

  1. 捆绑更新
  2. git add Gemfile.lock
  3. git commit -m '为 Heroku 更新 Gemfile.lock'
  4. git push heroku master

它对我有用。

运行:bundle lock --add-platform x86_64-linux

  1. 捆绑更新
  2. git add Gemfile.lock
  3. git commit -m '为 Heroku 更新 Gemfile.lock'
  4. git push heroku master

我很确定 Heroku 只支持某些版本的 Rails,因此您需要至少使用 3.0,而不是候选发布版本。 更新您的 gemfile 中的 Rails 版本,运行bundle update ,然后尝试推送到 Heroku。

我实际上通过在让事情静置几分钟后再次将其推上来解决了它......我从头开始重新旋转我的 dokku 系统并在我之前尝试解决方法的同一天遇到了同样的问题更新 nokogiri。 那是我意识到的时候,这似乎是herokuish的一个奇怪之处; 它并不总是第一次推动。

我想知道它是否在幕后安装库头文件,并且当它们花费太长时间时,bundler 只是安装失败。

我得到相同的 - 404:

curl -v -I http://rubygems.org/quick/Marshal.4.8/mail-2.2.6.001.gemspec.rz

在您的 Gemfile 中,您可以尝试指定此 gem 的较低版本号吗? 2.2.5 也许?

我的问题是关于 pg gem。

使用 'brew install postgres' 安装 postgres 捆绑完成后。

然后执行 Dyo Medio 描述的命令,我设法在 Heroku 上部署了应用程序。

我今天能够通过以下步骤清除缓存来解决这个问题(并被告知必须在每次部署时完成,直到找到并消除错误):首先安装插件:

  heroku plugins:install heroku-builds

然后使用以下命令清除缓存:

  heroku builds:cache:purge -a example-app

缓存将在下一次部署时重建。 如果您没有任何新代码要部署,您可以推送一个空提交。

  $ git commit --allow-empty -m "Purge cache"
  $ git push heroku master

其中 example-app 替换为您要为其清除缓存的应用程序的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM