tags:

views:

190

answers:

2

Hi guys,

I've just started playing with Ruby Version Manager (http://rvm.beginrescueend.com/rvm/cli/).

I have succefully configured rvm to use ruby 1.9.2 and everythin is fine.

However when I'm trying to do something using sudo no rvm or installed ruby is detected

administrator@hosting-live-2:~$ ruby -v ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] administrator@hosting-live-2:~$ sudo ruby -v [sudo] password for administrator: sudo: ruby: command not found

Is that correct behavior or i haven't configured RVM in right way.

May be I should use system wide install (http://rvm.beginrescueend.com/deployment/system-wide/)???

Regards, Alexey

A: 

Sudo is resetting your PATH. rvm works by modifying your PATH environment variable so that the ruby you're using is a particular one, probably in your ~/.rvm/rubies directory. When you ruby ruby with sudo, sudo is not using that modified PATH, and so it will not find your rvm ruby. See this question for workarounds: http://stackoverflow.com/questions/257616/sudo-changes-path-why

CaptainAwesomePants
+3  A: 

Use rvmsudo command instead of sudo

calas
+1 - Thanks calas! This worked awesomely for me. I have many gems that require me to use sudo when running them (such as RubyCAS) and this solved my problem eloquently. Thanks again!
Topher Fangio
thanks needed this to install passenger
MatthewFord