Can't install gems with sudo

G

Gavin Kistner

I just built ruby 1.8.5 myself, and now rubygems can't find remote gems =
when I run it with sudo privs. It can find the gems when I run it as =
myself, but then it doesn't have priviliges needed to install the gem. =
Did I miss something obvious?=20

[Sliver:~] gkistner$ which ruby
/usr/local/bin/ruby
[Sliver:~] gkistner$ which gem
/usr/local/bin/gem
[Sliver:~] gkistner$ ruby -v
ruby 1.8.5 (2006-08-25) [powerpc-darwin8.7.0]
[Sliver:~] gkistner$ gem -v
0.9.0
[Sliver:~] gkistner$ sudo gem install rake
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rake (> 0) in the repository
[Sliver:~] gkistner$ gem install rake
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - =
/usr/local/lib/ruby/gems/1.8/cache/rake-0.7.1.gem
 
C

Chris Gehlker

I just built ruby 1.8.5 myself, and now rubygems can't find remote
gems when I run it with sudo privs. It can find the gems when I run
it as myself, but then it doesn't have priviliges needed to install
the gem. Did I miss something obvious?

[Sliver:~] gkistner$ which ruby
/usr/local/bin/ruby
[Sliver:~] gkistner$ which gem
/usr/local/bin/gem
[Sliver:~] gkistner$ ruby -v
ruby 1.8.5 (2006-08-25) [powerpc-darwin8.7.0]
[Sliver:~] gkistner$ gem -v
0.9.0
[Sliver:~] gkistner$ sudo gem install rake
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rake (> 0) in the repository
[Sliver:~] gkistner$ gem install rake
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/local/lib/ruby/gems/1.8/cache/
rake-0.7.1.gem

OK, I get:

which ruby
/usr/local/bin/ruby
~ $ which gem
/usr/local/bin/gem
~ $ ruby -v
ruby 1.8.5 (2006-09-10) [powerpc-darwin8.7.0]
~ $ gem -v
0.9.0
~ $ sudo gem install rake
Successfully installed rake-0.7.1
Installing ri documentation for rake-0.7.1...
Installing RDoc documentation for rake-0.7.1...
~ $

You didn't miss anything obvious. I'm afraid that your problem is
subtle.
 
E

Eric Hodel

I just built ruby 1.8.5 myself, and now rubygems can't find remote
gems when I run it with sudo privs. It can find the gems when I run
it as myself, but then it doesn't have priviliges needed to install
the gem. Did I miss something obvious?

[Sliver:~] gkistner$ which ruby
/usr/local/bin/ruby
[Sliver:~] gkistner$ which gem
/usr/local/bin/gem
[Sliver:~] gkistner$ ruby -v
ruby 1.8.5 (2006-08-25) [powerpc-darwin8.7.0]
[Sliver:~] gkistner$ gem -v
0.9.0
[Sliver:~] gkistner$ sudo gem install rake
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rake (> 0) in the repository
[Sliver:~] gkistner$ gem install rake
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/local/lib/ruby/gems/1.8/cache/
rake-0.7.1.gem

Your source cache may be corrupt.

Try:

rm /usr/local/lib/ruby/gems/1.8/source_cache

(You also have one in ~/.gem/source_cache)
 
P

Phrogz

Paul said:
Looks like sudo might be giving you a dodgy path. Try this:

$ echo $PATH
$ sudo echo $PATH

Are they different?

Nope, identical path values.


Eric said:
Your source cache may be corrupt.

Try:
rm /usr/local/lib/ruby/gems/1.8/source_cache

Bingo, that was it! Thanks so much.
(Needed to "sudo rm ..." that file, of course - I include the
information here only for posterity.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,529
Members
45,001
Latest member
Kendra00E1

Latest Threads

Top