29

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

lorefnon
  • 12,112
  • 4
  • 54
  • 87
Mohit Jain
  • 40,277
  • 53
  • 161
  • 272

1 Answers1

52

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.

https://rvm.io/integration/sudo

Xenyal
  • 1,834
  • 2
  • 21
  • 43
NARKOZ
  • 24,741
  • 6
  • 64
  • 88