I've just installed Ruby Enterprise Edition on a fresh Ubuntu 10.04 server. I went to install my first gem, and hit a weird problem I never saw before.
Without sudoing, if I just type 'gem' I get the blurb about gem. I can switch to root and do gem install gemname
or give the full path to the gem exe, but if I do sudo gem install gemname
I get an odd error sudo: gem: command not found
.
If I do gem install gemname
without sudo, it tells me I don't have permission to alter the gem folder (which is fair enough). It looks like something funny's happening when I sudo, basically.
I've added the Ruby bin path to my PATH variable in my .bashrc file, like so:
export PATH=/opt/ruby-enterprise-1.8.7-2011.01/bin:$PATH
then reloaded .bashrc with source
. Any ideas, anyone?
try
sudo -s
and thengem install gemname
.Long Answer .bashrc file only affects the bash shell you are in, and sudo does not know about it because sudo does not directly look at your .bashrc. You can use
sudo -s
to get around this. You can also usesudo -E
to try to preserve the environment while running sudo commands.Using /etc/profile to change your PATH instead of .bashrc can also work as well.