我正在学习 Rails 3.2 版的Ruby on Rails 教程,并且快到第 5 章的末尾了。虽然它在几天前接受了我的代码,但 Heroku 不再希望在我推送时接受它。它抱怨它需要一个 Gemfile.lock,我可以理解——但我已经提供了一个。
几天前,我确实从存储库中删除了 Gemfile.lock,因为我在 Windows 上启动了这个项目并因此陷入了 Bundler 地狱。当时我在.gitignore中添加了Gemfile.lock的名称,但现在我已经从.gitignore中删除了它的名称并重新添加了它;然而 Heroku 仍然认为它没有被承诺。
我能做些什么?除了在当前阶段重新添加 Gemfile.lock 之外,我还尝试使用变基来删除首先删除它的提交。我还从 Heroku 中完全删除了该应用程序并重新添加了它(使用相同的名称和不同的名称)。此外,虽然我没有在 shell 会话中捕获它,但我确实在bundle update
这一切之前运行以确保 Gemfile.lock 与 Gemfile 匹配。
这是我的 bash 会话:
$ type ssha-heroku
ssha-heroku is aliased to `eval `ssh-agent`; ssh-add -t 5m ~/.ssh/heroku.id_rsa'
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ ssha-heroku
Agent pid 19642
Enter passphrase for /Users/eric/.ssh/heroku.id_rsa:
Identity added: /Users/eric/.ssh/heroku.id_rsa (/Users/eric/.ssh/heroku.id_rsa)
Lifetime set to 300 seconds
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ git push heroku master
Counting objects: 384, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (260/260), done.
Writing objects: 100% (384/384), 60.58 KiB, done.
Total 384 (delta 172), reused 215 (delta 86)
-----> Ruby/NoLockfile app detected
!
! Gemfile.lock required. Please check it in.
!
! Heroku push rejected, failed to compile Ruby/nolockfile app
To git@heroku.com:stormy-coast-5058.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:stormy-coast-5058.git'
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ git ls-files |grep Gemfile
Gemfile
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ vim .gitignore # here I remove the line ignoring Gemfile.lock
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ git add .gitignore Gemfile.lock
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ git commit -m 'Stop ignoring Gemfile.lock so we can deploy to Heroku'
[master 1b691f1] Stop ignoring Gemfile.lock so we can deploy to Heroku
2 files changed, 182 insertions(+), 6 deletions(-)
create mode 100644 Gemfile.lock
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ git ls-files |grep Gemfile
Gemfile
Gemfile.lock
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$ git push heroku master
Counting objects: 387, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (263/263), done.
Writing objects: 100% (387/387), 60.90 KiB, done.
Total 387 (delta 174), reused 215 (delta 86)
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have added to the Gemfile:
* rb-inotify (~> 0.9)
* libnotify (= 0.5.9)
You have deleted from the Gemfile:
* rb-fsevent (= 0.9.1)
* terminal-notifier-guard (= 1.5.3)
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
To git@heroku.com:stormy-coast-5058.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:stormy-coast-5058.git'
ruby-1.9.3-p392@railstutorial3 ~/Scripts/Rails/railstutorial/sample_app
$