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/unicorn
doesn't know where to find Ruby because it's managed via RVM. Normally, your .bashrc
or 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_ruby
that loads up RVM's 1.9.2p180 environment and then executes ruby
, execute the following:
rvm wrapper ruby-1.9.2-p180 system ruby
For more information and more details, check out this answer of mine, which addresses a similar problem.
Symlink also works,
which ruby<your version>
ln-s /ruby/path/ruby<your version> /ruby/path/ruby
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With