Gemfile.lock未签入 – Heroku

在尝试“git push heroku master”时,我不断收到错误消息:

Counting objects: 266, done. Delta compression using up to 4 threads. Compressing objects: 100% (239/239), done. Writing objects: 100% (266/266), 222.68 KiB, done. Total 266 (delta 55), reused 0 (delta 0) -----> 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... Using --without development:test You have modified your Gemfile in development but did not check the resulting snapshot (Gemfile.lock) into version control You have deleted from the Gemfile: * version: 1.0.6 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:freezing-frost-65.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku.com:freezing-frost-65.git' 

我尝试将Gemfile和Gemfile.lock添加到git但无济于事。 我尝试删除.bundle目录和Gemfile.lock,但同样的错误。

Bundler版本1.0.6存在问题您需要在开发计算机上运行“gem update bundler”以将bundler更新为1.0.7。 然后,您需要在应用程序中运行bundle update以生成新的Gemfile.lock文件。 您将看到Gemfile.lock已更新。 提交这个新的Gemfile.lock并再次推送到heroku。

我通过打开Gemfile.lock并删除以下两行来修复我的问题:

 PLATFORMS x86-mingw32 

所以现在我只需要创建一个捆绑包然后从锁定文件中删除它的脚本。

GemfileGemfile.lock文件都需要包含在git存储库中。 确保您没有在.gitignore文件中忽略它们。

此外,请确保在本地计算机上使用Bundler> = 1.0.0生成Gemfile.lock 。 我使用的是过时的版本,比如Bundler 0.9x,它会失败。

最后但同样重要的是,如果你有Gemfile.lock,请更新它。

 $ cd /path/to/project $ bundle update 

我在我的Gemfile.lock文件中删除了PLATFORMS下的“mingw”行,添加并提交给git,将其推送到git,然后将所有内容推送到heroku,显然它现在正常工作。

在您的applicaton目录中,在bin子目录中修改文件

 bin/bundle bin/rails bin/rake 

代替

 '#!/usr/bin/env ruby.exe 

一定是

 '#!/usr/bin/env ruby 

(感谢上一篇文章)

确保gemfile.lock中没有对windows的引用 – 它们可以被删除。

然后

 git push heroku master 

如果仍然存在问题,请使用heroku logs (将文本复制到文本编辑器可以更轻松地剪切和粘贴解决方案)。