Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RubyGems installation errors both when using 'sudo' and not using sudo

I have a machine that is running Ubuntu Hardy, which provides its own RubyGems package. Unfortunately that version of RubyGems (1.1.1) is too old to do anything useful with, so I decided to manually update RubyGems to the current version (1.3.6). That part went smoothly, and if I do gem -v, I get 1.3.6 which is expected. The problem is when I try to do: sudo gem install rack, it returns this error:

ERROR:  While executing gem ... (Errno::EACCES)
Permission denied - /home/username/.gem

Usually when I install gems as root, it knows to install it into /usr/lib/ruby/gems, so why is it checking my home directory at all? Another quirk is when I do gem install rack (not as root), it says:

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/lib/ruby/gems/1.8 directory.

which is where I want it to go. I've already tried clearing source_caches, trying different versions of RubyGems (1.3.5), forcing installation into /usr/lib with -i to no avail. Any ideas on why RubyGems is so insistent on checking my /home directory when installing as root?

like image 467
Kenny Peng Avatar asked Nov 26 '22 12:11

Kenny Peng


1 Answers

Sounds like it could be a path issue coupled with having multiple versions installed.

Any difference in output between:

sudo gem env

and

gem env
like image 177
SundayEdition Avatar answered Dec 06 '22 23:12

SundayEdition