简体   繁体   English

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

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

I am struggling to push my code to Heroku. And after searching on Google and Stack Overflow questions, I have not been able to find the solution.我正在努力将我的代码推送到 Heroku。在搜索 Google 和 Stack Overflow 问题后,我一直无法找到解决方案。 Here is What I get when I try "git push heroku master":这是我尝试“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'
.
....

And finally:最后:

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'

Thanks for your help!谢谢你的帮助!

I don't think it's a Rails version problem, nor is it specific to Heroku.我不认为这是 Rails 版本问题,也不是 Heroku 特有的问题。 (I hit the same problem today, when running bundle install on my local development machine, with Rails 3.0.3.) (我今天遇到了同样的问题,在我的本地开发机器上运行bundle install时,使用 Rails 3.0.3。)

Running bundle update locally, as Andrew suggested, fixes the issue.正如安德鲁建议的那样,在本地运行bundle update解决这个问题。

Edit : As suggested in the comments: remember to git add .编辑:正如评论中所建议的:记得git add . , git commit -m "message" , git commit -m "message"

I solved this issue this way:我是这样解决这个问题的:

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

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

if you see the problem is this:如果你看到问题是这样的:

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.

its mean this :它的意思是:

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.

If you see in your gemfile.loc you only have this :如果你在你的 gemfile.loc 中看到你只有这个:

PLATFORMS
  x86_64-darwin-16

So I did this command, To add in your platform in gemfile.loc所以我做了这个命令,在 gemfile.loc 中添加你的平台

bundle lock --add-platform x86_64-linux

This will update your Gemfile.loc :这将更新您的 Gemfile.loc :

PLATFORMS
  x86_64-darwin-16
  x86_64-linux

Continue :继续:

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

Push again再推

git push heroku master:main

Solve!解决!

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

Use:使用:

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

I had Gemfile.lock at my localserver make sure to delete it from the localserver AND also the HEROKU V-machine.我在我的本地Gemfile.lock上有Gemfile.lock确保从本地服务器和 HEROKU V 机器中删除它。

Another tip: Open your Gemfile.lock and check if this block exists:另一个提示:打开你的 Gemfile.lock 并检查这个块是否存在:

PLATFORMS
  x86_64-darwin-20

If it exists, run the following command: bundle config force_ruby_platform true如果存在,请运行以下命令: bundle config force_ruby_platform true

Now, you must recreate the whole Gemfile.lock, because some gems can be builded just for MacOS.现在,您必须重新创建整个 Gemfile.lock,因为有些 gem 可以只为 MacOS 构建。 So, just remove the Gemfile.lock and run bundle install (do no forget to stop spring, if it's running, otherwise spring automatically recreates the Gemfile.lock file)所以,只需删除Gemfile.lock并运行bundle install (不要忘记停止 spring,如果它正在运行,否则 spring 会自动重新创建 Gemfile.lock 文件)

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

it worked for me.它对我有用。

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

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

I'm pretty sure Heroku only supports certain versions of Rails, so you need to be on at least 3.0, instead of a release candidate.我很确定 Heroku 只支持某些版本的 Rails,因此您需要至少使用 3.0,而不是候选发布版本。 Update the version of Rails in your gemfile, run bundle update , and then try to push to Heroku.更新您的 gemfile 中的 Rails 版本,运行bundle update ,然后尝试推送到 Heroku。

I actually solved it by simply pushing it up a second time after letting things sit for a few minutes... I have re-spun my dokku system from scratch and encountered the same issue, on the same day after I had previously attempted a workaround of updating nokogiri.我实际上通过在让事情静置几分钟后再次将其推上来解决了它......我从头开始重新旋转我的 dokku 系统并在我之前尝试解决方法的同一天遇到了同样的问题更新 nokogiri。 That was when I realized, this seems to be an oddity of herokuish;那是我意识到的时候,这似乎是herokuish的一个奇怪之处; it doesn't always take on the first push.它并不总是第一次推动。

I wonder if behind the scenes it's installing library headers, and when they take too long, bundler simply fails the install.我想知道它是否在幕后安装库头文件,并且当它们花费太长时间时,bundler 只是安装失败。

I get the same - 404:我得到相同的 - 404:

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

In your Gemfile you could try specifying a lower version number of this gem?在您的 Gemfile 中,您可以尝试指定此 gem 的较低版本号吗? 2.2.5 perhaps? 2.2.5 也许?

My problem was about pg gem.我的问题是关于 pg gem。

After installing postgres with 'brew install postgres' bundling finished.使用 'brew install postgres' 安装 postgres 捆绑完成后。

Then doing commands Dyo Medio described, I managed to deploy the app on Heroku.然后执行 Dyo Medio 描述的命令,我设法在 Heroku 上部署了应用程序。

I was able to overcome this very issue today by purging the cache with steps (and was told it has to be done with each deployment until the bug is found and squashed): First install the plugin:我今天能够通过以下步骤清除缓存来解决这个问题(并被告知必须在每次部署时完成,直到找到并消除错误):首先安装插件:

  heroku plugins:install heroku-builds

Then use the following command to clear the cache:然后使用以下命令清除缓存:

  heroku builds:cache:purge -a example-app

The cache will be rebuilt on the next deploy.缓存将在下一次部署时重建。 If you do not have any new code to deploy, you can push an empty commit.如果您没有任何新代码要部署,您可以推送一个空提交。

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

Where example-app is replaced by the name of the app you want to clear the cache for.其中 example-app 替换为您要为其清除缓存的应用程序的名称。

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

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