Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Develop on windows, run unicorn in production on heroku

I have a new Rails project and i decided to give heroku a try, deployment seems very easy there

I am developing on windows, so running unicorn is not a choice, but webrick is fine for development

BUT, when it come to deployment , i want to use unicorn, and heroku perfectly support this

The Problem Is: i have to list unicorn on my Gemfile in order for heroku to pick it, but when i do that and run bundle command (or rails s) on my windows dev machine, it tries to install the unicorn server

i tried to put unicorn in the production group, group :production do gem 'unicorn' end still bundle complain and i cannot run the dev server

like image 743
Joseph Avatar asked May 26 '12 06:05

Joseph


2 Answers

You can target specific platforms in your Gemfile:

platforms :ruby do # linux
  gem 'unicorn'
end

platforms :mswin do
  # gems specific to windows
end

see the manpages for gemfile for more information.

like image 55
jigfox Avatar answered Oct 10 '22 15:10

jigfox


The alternative solution (which the original poster was very close to) is

group :production do
  gem 'unicorn'
end

and then using

bundle install --without production

on your Windows machine.

Heroku sidenote (not tested)

Unlike the accepted answer, this should not cause Heroku to ignore your Gemfile.lock

This is because Heroku checks your Gemfile for mswin and mingw when deciding if it is Windows generated or not.

like image 42
Felix Avatar answered Oct 10 '22 15:10

Felix