Reputation: 15069
I have RVM installed, it was installed as root. The permissions are:
drwxrwsr-x 23 root rvm 4096 2011-09-17 15:22 rvm
Here is an example of my trying to install a gem as sudo:
ubuntu@ip-10-2-15-243:/usr/local/rvm$ sudo gem install bundler
Successfully installed bundler-1.0.18
1 gem installed
Installing ri documentation for bundler-1.0.18...
Installing RDoc documentation for bundler-1.0.18...
ubuntu@ip-10-2-15-243:/usr/local/rvm$ gem list
*** LOCAL GEMS ***
rake (0.9.2)
The strange thing is that if I "sudo su -" and then install the gem as root, it works. Is it a problem with how ubuntu is listed in the sudoers file?
ubuntu ALL=(ALL) NOPASSWD:ALL
I did edit sudoers with VIM, and it told me to use VISUDO so I'm not sure if that created a problem.
Upvotes: 0
Views: 2461
Reputation: 16
I had the same problem and this worked for me. It turns out that all other methods installed into the global gemset, which is why the command returns without an error
script 'bundle gems' do
user 'root'
code <<-EOH
. "/usr/local/rvm/scripts/rvm"
cd /your/directory
rvm rvmrc trust
BUNDLE_WITHOUT=test bundle install
exit $?
EOH
interpreter 'bash'
end
Upvotes: 0
Reputation: 984
The RVM environment is probably not loaded by sudo.
Try running:
sudo -i gem install bundler
-i is : "simulate initial login"
Sorry but I can not verify it by myself at the moment.
Upvotes: 0
Reputation: 65435
Try using rvmsudo
instead of sudo
.
If this is in the context of a chef run, you can use this resource:
execute "gem-install-bundler" do
user "root"
command <<-COMMAND
bash -c '
source {{{/path/to/rvm}}}
rvm use {{{ruby-version}}}
gem install bundler
'
COMMAND
end
Upvotes: 1