【问题标题】:Heroku push rejected, failed to install gems via BundlerHeroku 推送被拒绝,无法通过 Bundler 安装 gem
【发布时间】:2011-06-02 05:31:45
【问题描述】:

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

感谢您的帮助!

【问题讨论】:

    标签: ruby-on-rails rubygems heroku ruby-on-rails-3 bundler


    【解决方案1】:

    我有同样的问题: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
    

    解决!

    【讨论】:

    • 感谢您的评论。我刚刚转移到 M1 MacBook Air 进行 Rails 开发,这解决了我的 Heroku 推送问题。
    【解决方案2】:
    bundle lock --add-platform ruby
    bundle lock --add-platform x86_64-linux
    bundle install
    git add .
    git commit -m "Bundler fix"
    

    【讨论】:

    • 感谢您添加答案,欢迎来到 SO!您可以通过将它们放在代码块中来添加连续的代码行(请参阅meta.stackexchange.com/questions/216464/…)。在您的答案中包含一些关于代码在做什么以及它如何解决问题的解释性文本通常也被认为是一种好的做法。
    • 这看起来像是更干净的解决方案,因为设置 force_ruby_platform 配置将保留用于所有项目,这可能不是您想要的。此外,Heroku 部署似乎需要同时设置 ruby​​ 和 linux 平台(检查此问题:github.com/rubygems/rubygems/issues/4269#issuecomment-759591430
    【解决方案3】:

    运行:捆绑锁 --add-platform x86_64-linux

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

    【讨论】:

      【解决方案4】:

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

      【讨论】:

        【解决方案5】:
        1. 捆绑更新
        2. git add Gemfile.lock
        3. git commit -m '为 Heroku 更新 Gemfile.lock'
        4. git push heroku master

        它对我有用。

        【讨论】:

          【解决方案6】:

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

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

          【讨论】:

            【解决方案7】:

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

            按照 Andrew 的建议,在本地运行 bundle update 可以解决问题。

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

            【讨论】:

              【解决方案8】:

              我通过这种方式解决了这个问题:

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

              【讨论】:

                【解决方案9】:

                用途:

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

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

                【讨论】:

                  【解决方案10】:

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

                  【讨论】:

                    【解决方案11】:

                    我也一样 - 404:

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

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

                    【讨论】:

                    • 我认为它在 Heroku 方面,因为我的 Gemfile 非常简单:gem 'rails', '3.0.0.rc' gem 'twitter_oauth' gem 'json' gem 'pg'跨度>
                    • 您使用旧的预发布版本 Rails 有什么原因吗?你为什么不看看指定 3.0.3 是否适合你?
                    猜你喜欢
                    • 1970-01-01
                    • 2012-06-07
                    • 2012-10-10
                    • 2016-05-07
                    • 2015-09-23
                    • 2019-01-07
                    • 2021-08-27
                    相关资源
                    最近更新 更多