rvmsudo vs sudo?

Mohit Jain picture Mohit Jain · Apr 28, 2011 · Viewed 18.1k times · Source

I just moved to RVM.

sudo bundle install gives me and error:-

 sudo bundle install
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:900:in `report_activate_error': Could not find RubyGem bundler (>= 0) (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:248:in `activate'
from /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1276:in `gem'
from /usr/local/rvm/gems/ruby-1.9.2-p180/bin/bundle:18:in `<main>'

and

rvmsudo bundle install 

works like a charm. Whats the difference. Whats going on behind the screen. Can anybody explain..

Answer

NARKOZ picture NARKOZ · Apr 28, 2011

sudo starts a new subshell that does not contain environment variables.
rvmsudo passes on any environment variables that RVM set up to get you to the correct Ruby. This includes the $PATH as well has $GEM_HOME, $GEM_PATH and $BUNDLE_PATH variables.

http://ruby.about.com/od/rubyversionmanager/qt/Rvm-And-Sudo.htm