无法推送到Heroku。不明白什么是错的

时间:2013-08-31 16:02:03

标签: ruby-on-rails ruby git heroku bundler

输出:

Counting objects: 96, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (73/73), done.
Writing objects: 100% (73/73), 7.87 KiB | 0 bytes/s, done.
Total 73 (delta 56), reused 0 (delta 0)

-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
       Fixing nokogiri install. Clearing bundler cache.
       See https://github.com/sparklemotion/nokogiri/issues/923.
       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:
       * postmark-rails (~> 0.5.2)
       You have deleted from the Gemfile:
       * postmark-rails
       Bundler Output: 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:
       * postmark-rails (~> 0.5.2)

       You have deleted from the Gemfile:
       * postmark-rails
 !
 !     Failed to install gems via Bundler.
 !

 !     Push rejected, failed to compile Ruby/Rails app

Auto packing the repository for optimum performance.
To git@heroku.com:sutra-staging.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:sutra-staging.git'
Everything up-to-date

我的Gemfile.lock处于版本控制状态。

2 个答案:

答案 0 :(得分:5)

您说您的Gemfile.lock处于版本控制状态,但您的错误消息却表示Gemfile.lock与您的Gemfile不匹配。

您需要在bundle install本地提交修改后的Gemfile.lock

答案 1 :(得分:3)

发生的事情是您更改了Gemfile,但是您没有使用Bundler本地更新您的Gem。这意味着您的Gemfile文件和Gemfile.lock文件不同步。

要解决此问题,请运行bundle install,提交更改,然后再次推送到Heroku。这将安装您添加的postmark-rails gem,更新Gemfile.lock并让所有内容重新同步。

可能让您困惑的是使用gem install安装宝石不会更新Bundler知道的宝石。 Bundler的工作是管理项目的宝石,所以每次添加新gem时,请确保运行Bundler来更新内容。