Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM & Unicorn deploy

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

like image 286
Kir Avatar asked Jun 06 '11 16:06

Kir


2 Answers

/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.

like image 129
Michelle Tilley Avatar answered Sep 24 '22 10:09

Michelle Tilley


Symlink also works,

which ruby<your version>
ln-s /ruby/path/ruby<your version> /ruby/path/ruby
like image 23
Stephen Avatar answered Sep 23 '22 10:09

Stephen