如何解决 heroku "You are trying to install in deployment mode after changing your Gemfile" 错误?

How to resolve heroku "You are trying to install in deployment mode after changing your Gemfile" error?

我知道这个问题已经出现在 SA 上了 --- 但是,没有任何东西能为我解决这个问题。我知道这只是表明我的 gemfile 和 gemfile.lock 文件不同步。删除 gemfile.lock 文件并重新捆绑应该可以解决此问题。我已经尝试了很多次调整我的 gemfile、提交和推送的尝试——但是,没有任何效果。任何熟悉这个 heroku 堆栈跟踪的人都可以提供一些指导吗?这对我来说突然改变了。

尝试次数:

- remove gemfile.lock and bundle install
- update bundler
- remove older versions of multiple installed gems
- 

git push heroku
 Counting objects: 41, done.
 Delta compression using up to 4 threads.
 Compressing objects: 100% (40/40), done.
 Writing objects: 100% (41/41), 5.64 KiB | 0 bytes/s, done.
 Total 41 (delta 27), reused 0 (delta 0)

 remote: Compressing source files... done.
 remote: Building source:
 remote:
 remote: -----> Ruby app detected
 remote: -----> Compiling Ruby/Rails
 remote: -----> Using Ruby version: ruby-2.3.1
 remote: -----> Installing dependencies using bundler 1.13.6
 remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
 remote:        The git source `git://github.com/rails/sprockets-rails.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/sinatra/sinatra.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/jonatack/will_paginate.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/kesha-antonov/simple_form.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/sonalkr132/spring.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        You are trying to install in deployment mode after changing
 remote:        your Gemfile. Run `bundle install` elsewhere and add the
 remote:        updated Gemfile.lock to version control.
 remote:        You have added to the Gemfile:
 remote:        * source: git://github.com/jonatack/will_paginate.git (at master)
 remote:        * source: git://github.com/kesha-antonov/simple_form.git (at rails-5-0)
 remote:        * source: git://github.com/rails/sprockets-rails.git (at master)
 remote:        * source: git://github.com/sinatra/sinatra.git (at master)
 remote:        * source: git://github.com/sonalkr132/spring.git (at bundler-dep)
 remote:        You have deleted from the Gemfile:
 remote:        * source: https://github.com/jonatack/will_paginate.git (at master@3c86149)
 remote:        * source: https://github.com/kesha-antonov/simple_form.git (at
 remote:        rails-5-0@a1561c9)
 remote:        * source: https://github.com/rails/sprockets-rails.git (at master@6fa795a)
 remote:        * source: https://github.com/sinatra/sinatra.git (at master@63e81bc)
 remote:        * source: https://github.com/sonalkr132/spring.git (at bundler-dep@0caed19)
 remote:        Bundler Output: The git source `git://github.com/rails/sprockets-rails.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/sinatra/sinatra.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/jonatack/will_paginate.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/kesha-antonov/simple_form.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        The git source `git://github.com/sonalkr132/spring.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
 remote:        You are trying to install in deployment mode after changing
 remote:        your Gemfile. Run `bundle install` elsewhere and add the
 remote:        updated Gemfile.lock to version control.
 remote:
 remote:        You have added to the Gemfile:
 remote:        * source: git://github.com/jonatack/will_paginate.git (at master)
 remote:        * source: git://github.com/kesha-antonov/simple_form.git (at rails-5-0)
 remote:        * source: git://github.com/rails/sprockets-rails.git (at master)
 remote:        * source: git://github.com/sinatra/sinatra.git (at master)
 remote:        * source: git://github.com/sonalkr132/spring.git (at bundler-dep)
 remote:
 remote:        You have deleted from the Gemfile:
 remote:        * source: https://github.com/jonatack/will_paginate.git (at master@3c86149)
 remote:        * source: https://github.com/kesha-antonov/simple_form.git (at
 remote:        rails-5-0@a1561c9)
 remote:        * source: https://github.com/rails/sprockets-rails.git (at master@6fa795a)
 remote:        * source: https://github.com/sinatra/sinatra.git (at master@63e81bc)
 remote:        * source: https://github.com/sonalkr132/spring.git (at bundler-dep@0caed19)
 remote:  !
 remote:  !     Failed to install gems via Bundler.
 remote:  !
 remote:  !     Push rejected, failed to compile Ruby app.
 remote:
 remote:  !     Push failed
 remote: Verifying deploy...
 remote:
 remote: !  Push rejected to xxxxxx.
 remote:
 To git@heroku.com:xxxxxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)
 error: failed to push some refs to 'git@heroku.com:xxxxxx.git'

大多数答案仅表示删除 gemfile.lock 和 运行 捆绑安装。然而---关于 https:

的捆绑器弹出了一条新消息
The git source `X` uses the `git` protocol, which transmits data without
encryption. Disable this warning with `bundle config git.allow_insecure true`,
or switch to the `https` protocol to keep your data secure.

按照消息提示在 ~/.bundle/config 中创建了一个新的配置文件。这个文件让 heroku 陷入困境——删除它让我重新开始工作。

不幸的是,heroku 的堆栈跟踪没有提供真正的方向来解决这个问题。您可能会看到 "You are trying to install in deployment mode after changing your Gemfile" 消息的原因有很多 --- 而且,heroku 没有提供任何帮助您找出它不高兴的原因。

强制 heroku 使用 https:// 而不是 git:// 协议,添加 BUNDLE_GITHUB__HTTPS (注意双下划线)作为环境变量并将其设置为 true (在 Config Vars 部分的 Settings 选项卡下的 heroku 应用程序仪表板中)。