在windows上开发,在heroku上运行独角兽
我有一个新的Rails项目,我决定尝试heroku,部署似乎很容易
我在windows上开发,所以运行独角兽不是一个选择,但webrick可以用于开发
但是,当它部署时,我想使用独角兽,而heroku完全支持这一点
问题是:我必须在我的Gemfile上列出独角兽以便heroku选择它,但当我这样做并在我的windows dev机器上运行bundle命令(或rails s)时,它会尝试安装unicorn服务器
我试图把独角兽放在生产组,组:生产做gem’独角兽’结束仍然捆绑抱怨,我无法运行开发服务器
您可以在Gemfile中定位特定平台:
platforms :ruby do # linux gem 'unicorn' end platforms :mswin do # gems specific to windows end
有关更多信息,请参阅gemfile的联机帮助页 。
替代解决方案(原始海报非常接近)是
group :production do gem 'unicorn' end
然后使用
bundle install --without production
在您的Windows机器上。
Heroku旁注 (未测试)
与接受的答案不同,这不应该导致Heroku忽略您的Gemfile.lock
这是因为Heroku在判断它是否是Windows生成时检查你的Gemfile是否有mswin
和mingw
。