My RVM is installed as root.
When I’m trying to start unicorn socket, it prints
user@9001-3:~$ /etc/init.d/unicorn start
Starting myapp app: /usr/bin/env: ruby: No such file or directory
unicorn.
But if I type
user@9001-3:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/unicorn path exists.
My unicorn config: https://gist.github.com/1010519
/etc/init.d/unicorndoesn’t know where to find Ruby because it’s managed via RVM. Normally, your.bashrcor similar file is executed and sets up the environment; this doesn’t happen in init scripts (or likely anything else executed by root).The solution is to use wrappers. For example, to create a binary called
system_rubythat loads up RVM’s 1.9.2p180 environment and then executesruby, execute the following:For more information and more details, check out this answer of mine, which addresses a similar problem.