Ruby-on-rails Heroku 推送被拒绝,无法通过 Bundler 安装 gems

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4574176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:59:33  来源:igfitidea点击:

Heroku push rejected, failed to install gems via Bundler

ruby-on-railsrubygemsherokuruby-on-rails-3bundler

提问by ismaelsow

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. Here is What I get when I try "git push heroku master" :

我正在努力将我的代码推送到 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'
.
....

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 [email protected]:myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:myapp.git'

Thanks for your help!

谢谢你的帮助!

回答by Jacob

I don't think it's a Rails version problem, nor is it specific to Heroku. (I hit the same problem today, when running bundle installon my local development machine, with Rails 3.0.3.)

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

Running bundle updatelocally, as Andrew suggested, fixes the issue.

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

Edit: As suggested in the comments: remember to git add ., git commit -m "message"

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

回答by Roman Krasavtsev

I solved this issue this way:

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

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

回答by Eran

Use:

用:

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

I had Gemfile.lockat my localserver make sure to delete it from the localserver AND also the HEROKU V-machine.

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

回答by Andrew

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. Update the version of Rails in your gemfile, run bundle update, and then try to push to Heroku.

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

回答by Ayush Jain

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

it worked for me.

它对我有用。

回答by Ninjaxor

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. That was when I realized, this seems to be an oddity of herokuish; it doesn't always take on the first push.

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

I wonder if behind the scenes it's installing library headers, and when they take too long, bundler simply fails the install.

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

回答by stef

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? 2.2.5 perhaps?

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