Kir
Kir

Reputation: 8111

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

Upvotes: 7

Views: 4870

Answers (4)

Phillipp
Phillipp

Reputation: 264

I had the same problem and this for me

rvm --default use <version>

Upvotes: 0

Stephen
Stephen

Reputation: 11

Symlink also works,

which ruby<your version>
ln-s /ruby/path/ruby<your version> /ruby/path/ruby

Upvotes: 1

Michelle Tilley
Michelle Tilley

Reputation: 159145

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

Upvotes: 11

Hartator
Hartator

Reputation: 5155

Type : which ruby (show the ruby bin path) then type this : ln -s (change_to_ruby_path) /usr/bin/env/ruby (construct the correct access for your system)

Upvotes: 0

Related Questions