Heroku部署Gemfile.lock问题

时间:2011-06-09 06:29:58

标签: ruby-on-rails deployment heroku

我对整个部署工作都很陌生。在我第一次创建应用程序之前,我已经部署了一次应用程序,然后一切似乎都运行正常。我现在对我的应用程序进行了一些更改,我想部署它们并确保它们在生产环境中工作。我添加并提交了我的最后一项更改,并将我的更改合并到我的主分支中。然后我跑了git push heroku master。我在输出中收到以下错误:

Gemfile detected, running Bundler version 1.0.7
   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

好的,所以我需要更新我的gemfile。首先,我检查了.gitignore文件的内容,其中包括:

.bundle
db/*.sqlite3*
log/*.log
*.log
/tmp/
doc/
*.swp
*~
.project
.DS_Store
.psd

Gemfile.lock似乎并不存在,但我还是尝试了以下方法:

git add .
git commit -m "updated Gemfile.lock"

然后我再次推到Heroku并得到同样的错误。接下来,我试过了:

git add Gemfile Gemfile.lock
git commit -m "updated Gemfile.lock (again)"

推后,我得到了同样的结果。在搜索了一会儿之后,我找到了this帖子,这促使我尝试以下内容:

gem update bundler
bundle update
git add Gemfile Gemfile.lock
git commit -m "updated Gemfile.lock (again (again))"

仍然没有运气,此时我几乎没有想法。我很感激任何建议。

3 个答案:

答案 0 :(得分:10)

事实证明答案非常简单。根据Heroku Support Guy,您不能在Gemfile中使用if语句。来自我的Gemfile的违规行是:

gem 'rb-fsevent', :require => true if (RUBY_PLATFORM =~ /darwin/i)

答案 1 :(得分:2)

我们在Linux和Mac上都使用Guard,并遇到了部署Heroku的相同问题。我们的解决方法是将Gem安装为插件而不是Gemfile中的条件。在我们的例子中,对Gemfile的更改如下:

# guard
gem "growl", "~> 1.0.3"
gem "guard-coffeescript", "0.4.1"
gem "guard-sass", "0.3.3"
gem "rb-fsevent", "0.4.3.1"
gem "libnotify"
#gem "rb-inotify", "~> 0.8.8", :require => false if RUBY_PLATFORM =~ /darwin/i

然后我们跑了:rails plugin install git://github.com/nex3/rb-inotify.git并且很高兴。

答案 2 :(得分:0)

你有一个Gemfile.lock文件吗?它应该与Gemfile存在于同一目录中。

如果没有,请运行“bundle install”。这应该创造它。

它仍然无法解决您的问题,那么我会尝试重新开始: 将你的git存储库克隆到一个新的空目录,运行bundle install,运行你的测试,启动你的开发服务器并玩游戏 - 简而言之,确保一切正常,然后尝试再次部署到heroku。

相关问题