Heroku部署Gemfile.lock问题

我对整个部署事情都很陌生。 在我第一次创建应用程序之前,我已经部署了一次应用程序,然后一切似乎都运行正常。 我现在对我的应用程序进行了一些更改,我想部署它们并确保它们在生产环境中工作。 我添加并提交了我的最后一项更改,并将我的更改合并到我的主分支中。 然后我跑了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)" 

推后,我得到了同样的结果。 在搜索了一会儿之后,我找到了这篇post,这促使我尝试以下方法:

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

仍然没有运气,而且我现在几乎没有想法。 我很感激任何建议。

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

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

我们在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并且很高兴。

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

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

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