Reputation: 51
root@app1:~# gem -v
1.8.10
I get 1.8.10 when I use rvm. But when I use sudo I get:
root@app1:~# sudo gem -v
1.3.7
Now when I install a gem on another user than root
test@app1:~$ gem install RedCloth
Fetching: RedCloth-4.2.8.gem (100%)
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/local/rvm/gems/ree-1.8.7-2011.03/cache/RedCloth-4.2.8.gem
Where does this go wrong?
Here is my gem env when i use no sudo
root@app1:~# gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ree-1.8.7-2011.03
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ree-1.8.7-2011.03/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ree-1.8.7-2011.03/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rvm/gems/ree-1.8.7-2011.03
- /usr/local/rvm/gems/ree-1.8.7-2011.03@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri"
- "install" => "--no-ri --no-rdoc --env-shebang"
- :sources => ["http://gemcutter.org", "http://gems.rubyforge.org/", "http://gems.github.com"]
- "update" => "--no-ri --no-rdoc --env-shebang"
- REMOTE SOURCES:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
Here is my gem env when i use sudo
root@app1:~# sudo gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /root/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri"
- :sources => ["http://gemcutter.org", "http://gems.rubyforge.org/", "http://gems.github.com"]
- "install" => "--no-ri --no-rdoc --env-shebang"
- "update" => "--no-ri --no-rdoc --env-shebang"
- REMOTE SOURCES:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
Upvotes: 0
Views: 1125
Reputation: 55718
Three things to note here:
sudo
clears most of them during user switch as a security measure to prevent attackers to inject dangerous variables like LD_PRELOAD
into an elevated execution context. If you want to use sudo and want to retain your RVM environment inside the new shell, use rvmsudo
instead.rvm
and makes sure that all its members can write to the RVm directory which is requires to install rubies, create gemsets and install gems. Make sure your user is in that group. Or you could just use rvmsudo
...Upvotes: 2