On my ubuntu machine, I can run unicorn on ruby 1.9.3, however, it does not seem to work with ruby 2.0. Any idea why?
root@dev:/home/karan# rvm use 1.9
Using /usr/local/rvm/gems/ruby-1.9.3-p429
root@dev:/home/karan# unicorn -v
unicorn v4.6.3
root@dev:/home/karan# rvm use 2.0
Using /usr/local/rvm/gems/ruby-2.0.0-p195
root@dev:/home/karan# unicorn -v
/usr/local/rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- unicorn/launcher (LoadError)
from /usr/local/rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /usr/bin/unicorn:3:in `<main>'
Try reinstalling the gem with 2.0.0.
The problem must have been caused by the fact the gem was installed in 1.9.3.
I have the exact same problem when I try to start Unicorn server
Starting Unicorn web server unicorn
/usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- unicorn/launcher (LoadError)
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/bin/unicorn:3:in `<main>'
Nevertheless, Unicorn works fine when I run it from the rails app folder, simply using "unicorn" command.
I have tried what you suggest, installing the gem unicorn
gem install 'unicorn'
But it does not change the result
I check what gem is installed:
which gem 'unicorn'
/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/gem
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn
I am running unicorn from a etc/init.d script that you can see here:
and here for the default configuration:
There seems to be some problem with the PATH of the default configuration file:
PATH=/usr/local/rvm/rubies/ruby-2.0.0-p353/bin:/home/unicorn/.rvm/bin:/usr/local/sbin:/usr/bin:/bin:/sbin:$
Because since I updated it with the new installed version I get the error message shown at the top. If I remove it, Unicorn "apparently starts" but the log shows a crazy activity and nginx shows an empty screen.
I am trying to find a solution and will share it here as soon as I find it.
Thanks for your help
* UPDATE *
OK I have found the problems:
1) for the /etc/init.d script:
You need to create a wrapper for Unicorn to work in a init.d type of script:
rvm wrapper 2.0.0 ruby-2.0.0 unicorn
then replace the line
DAEMON=/usr/bin/unicorn
with this one:
DAEMON=/usr/local/rvm/bin/ruby-2.0.0_unicorn
And now the command
service unicorn start
more on rvm wrapper here: https://rvm.io/integration/init-d
2) I also had another issue that was difficult to identify in the log:
I had not created a config/environments/staging.rb file
来源:https://stackoverflow.com/questions/18193506/cannot-run-unicorn-with-ruby-2-0