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

发布于 2024-10-09 14:52:54 字数 1395 浏览 2 评论 0原文

我正在努力将我的代码推送到 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 [email protected]:myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:myapp.git'

感谢您的帮助!

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 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

去了角落 2024-10-16 14:52:54

我有同样的问题:远程:!无法通过 Bundler 安装 gem。

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

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

解决!

I have same issue: 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 :

PLATFORMS
  x86_64-darwin-16

So I did this command, To add in your platform in gemfile.loc

bundle lock --add-platform x86_64-linux

This will update your 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!

心如荒岛 2024-10-16 14:52:54

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

按照 Andrew 的建议,在本地运行 bundle update 修复了问题。

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

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 install on my local development machine, with Rails 3.0.3.)

Running bundle update locally, as Andrew suggested, fixes the issue.

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

好多鱼好多余 2024-10-16 14:52:54

我这样解决了这个问题:

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

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
东北女汉子 2024-10-16 14:52:54
bundle lock --add-platform ruby
bundle lock --add-platform x86_64-linux
bundle install
git add .
git commit -m "Bundler fix"
bundle lock --add-platform ruby
bundle lock --add-platform x86_64-linux
bundle install
git add .
git commit -m "Bundler fix"
如梦 2024-10-16 14:52:54

另一个提示:
打开 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 文件)

Another tip:
Open your Gemfile.lock and check if this block exists:

PLATFORMS
  x86_64-darwin-20

If it exists, run the following command:
bundle config force_ruby_platform true

Now, you must recreate the whole Gemfile.lock, because some gems can be builded just for 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)

〗斷ホ乔殘χμё〖 2024-10-16 14:52:54

使用:

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

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

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.

等风来 2024-10-16 14:52:54
  1. Bundle update
  2. git add Gemfile.lock
  3. git commit -m 'Update Gemfile.lock for Heroku'
  4. git Push heroku master

它对我有用。

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

it worked for me.

雪花飘飘的天空 2024-10-16 14:52:54

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

  1. bundle update
  2. git add Gemfile.lock
  3. git commit -m 'Update Gemfile.lock for Heroku'
  4. git Push heroku master

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

  1. bundle update
  2. git add Gemfile.lock
  3. git commit -m 'Update Gemfile.lock for Heroku'
  4. git push heroku master
£烟消云散 2024-10-16 14:52:54

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

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.

梦开始←不甜 2024-10-16 14:52:54

我得到同样的结果 - 404:

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

在你的 Gemfile 中你可以尝试指定这个 gem 的较低版本号?也许是2.2.5?

I get the same - 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?

盗心人 2024-10-16 14:52:54

实际上,我只是在让事情静置几分钟后再次将其推高就解决了这个问题...我从头开始重新旋转我的 dokku 系统,并在我之前尝试解决方法后的同一天遇到了同样的问题更新 nokogiri。就在那时我意识到,这似乎是一种英雄主义的奇怪现象;它并不总是首先推动。

我想知道它是否在幕后安装库标头,当它们花费太长时间时,捆绑器就会安装失败。

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.

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

绻影浮沉 2024-10-16 14:52:54

我的问题是关于 pg gem 的。

使用“brew install postgres”安装 postgres 后,捆绑完成。

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

My problem was about pg gem.

After installing postgres with 'brew install postgres' bundling finished.

Then doing commands Dyo Medio described, I managed to deploy the app on Heroku.

◇流星雨 2024-10-16 14:52:54

我今天能够通过以下步骤清除缓存来克服这个问题(并被告知每次部署都必须完成此操作,直到发现并消除错误):
首先安装插件:

  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 替换为您要清除缓存的应用程序的名称。

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.

慢慢从新开始 2024-10-16 14:52:54

对我来说,我的 git 存储库中有来自 vendor/cache 的文件,这就是问题所在(即使 vendor/cache 已经在我的 gitignore 中)。

无论如何:
vendor/cache 添加到您的 gitignore(如果尚未添加)并运行

git rm -r --cached vendor/cache

For me, I had files from vendor/cache in my git repo and that was the issue (even though vendor/cache was already in my gitignore).

Anyways:
Add vendor/cache to your gitignore if you haven't already and run

git rm -r --cached vendor/cache
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文