在先前将Gemfile.lock从存储库中取出后,将Rails应用程序部署到Heroku
我正在学习的是Rails 3.2版,第5章即将结束。虽然几天前它接受了我的代码,但Heroku不再想在我推的时候接受它。它抱怨它需要一个Gemfile.lock,我可以理解,但我已经提供了一个 几天前,我确实从存储库中删除了Gemfile.lock,因为我在Windows上启动了这个项目,并因此遇到了Bundler地狱。当时,我将Gemfile.lock的名称添加到了.gitignore中,但现在我已将其名称从.gitignore中删除并重新添加;然而,赫罗库仍然认为这是没有承诺的 我能做什么?除了在当前阶段重新添加Gemfile.lock之外,我还尝试使用重定基来删除一开始删除它的提交。我还从Heroku中完全删除了该应用程序,并重新添加了它(使用相同的名称和不同的名称)。此外,尽管我没有在shell会话中捕获它,但在所有这些之前,我确实运行了在先前将Gemfile.lock从存储库中取出后,将Rails应用程序部署到Heroku,heroku,bundler,railstutorial.org,Heroku,Bundler,Railstutorial.org,我正在学习的是Rails 3.2版,第5章即将结束。虽然几天前它接受了我的代码,但Heroku不再想在我推的时候接受它。它抱怨它需要一个Gemfile.lock,我可以理解,但我已经提供了一个 几天前,我确实从存储库中删除了Gemfile.lock,因为我在Windows上启动了这个项目,并因此遇到了Bundler地狱。当时,我将Gemfile.lock的名称添加到了.gitignore中,但现在我已将其名称从.gitignore中删除并重新添加;然而,赫罗库仍然认为这是没有承诺的 我能做什么?
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
$
我最终将问题追溯到这样一个事实:我根据平台(Mac、Linux和Windows)为防护通知指定了不同的gem;但是当我在Mac上运行
bundle install
时,它不会将Linux或Windows gems锁定在Gemfile.lock中。我确实在一个检测主机平台的案例
语句中包含了这些宝石,但显然Bundler无法从中分辨出我的意图
我去掉了所有条件,只指定了Mac gems,而不是其他平台。在今后的某个时候,我将进一步调查;由于这些gem仅用于测试,我认为Heroku的Bundler根本不需要了解它们。我最终将问题追溯到,我根据平台(Mac、Linux和Windows)为防护通知指定了不同的gem;但是当我在Mac上运行
bundle install
时,它不会将Linux或Windows gems锁定在Gemfile.lock中。我确实在一个检测主机平台的案例
语句中包含了这些宝石,但显然Bundler无法从中分辨出我的意图
我去掉了所有条件,只指定了Mac gems,而不是其他平台。在今后的某个时候,我将进一步调查;由于这些宝石只是测试用的,我认为Heroku的捆绑机根本不需要了解它们