2013-04-08 57 views
1

我正在通過Rails 3.2版的Ruby on Rails Tutorial,並且接近第5章的末尾。雖然它幾天前接受了我的代碼,但Heroku當我推動時不再想要接受它。它抱怨說它需要一個Gemfile.lock,我可以理解 - 但我已經提供了一個。先前將Gemfile.lock從存儲庫中取出後部署Rails應用程序

幾天前,我從存儲庫中刪除了Gemfile.lock,因爲我在Windows上啓動了這個項目,並因此而跑到Bundler地獄。那時,我將Gemfile.lock的名字添加到.gitignore中,但現在我已經從.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' 

[email protected] ~/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 

[email protected] ~/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 [email protected]:stormy-coast-5058.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]:stormy-coast-5058.git' 

[email protected] ~/Scripts/Rails/railstutorial/sample_app 
$ git ls-files |grep Gemfile 
Gemfile 

[email protected] ~/Scripts/Rails/railstutorial/sample_app 
$ vim .gitignore # here I remove the line ignoring Gemfile.lock 

[email protected] ~/Scripts/Rails/railstutorial/sample_app 
$ git add .gitignore Gemfile.lock 

[email protected] ~/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 

[email protected] ~/Scripts/Rails/railstutorial/sample_app 
$ git ls-files |grep Gemfile 
Gemfile 
Gemfile.lock 

[email protected] ~/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 [email protected]:stormy-coast-5058.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]:stormy-coast-5058.git' 

[email protected] ~/Scripts/Rails/railstutorial/sample_app 
$ 

回答

1

我終於追蹤到問題重新回到我指定衛隊通知取決於平臺(蘋果機,Linux和Windows)的不同寶石的事實;但是當我想要在我的Mac上運行bundle install它不會鎖定Gemfile.lock中的Linux或Windows gem。我確實在檢測主機平臺的case聲明中有這些寶石,但顯然Bundler無法完全說明我的意圖。

我採取了整個條件,只是指定了Mac的寶石,而不是其他平臺'。一段時間以後,我會進一步調查;因爲這些寶石只用於測試,我不認爲Heroku的Bundler需要了解它們。

相關問題