Must .gemrc -> gemhome point to Gems installation?

E

ES

On my system, anything in the gemhome field in .gemrc seems to render
Gems unusable. Here's some output for your viewing pleasure:

# Version
05:45:46 ruerue@purr> ruby -v
ruby 1.8.2 (2004-12-25) [i686-linux]

05:51:28 ruerue@purr> gem --version
0.8.6

# This is what I'd like to have
05:51:35 ruerue@purr> cat .gemrc
gem: --gen-rdoc --run-tests
rdoc: --all --line-numbers --inline-source
gemhome: /home/ruerue/lib/ruby
gempath:
- /usr/lib/ruby/site_ruby/1.8/rubygems

# But then this happens
05:51:55 ruerue@purr> gem install -r og
Attempting remote installation of 'og'
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:131:in `activate': (Gem::LoadError)
Could not find RubyGem sources (> 0.0.0)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:34:in `require_gem'
# Backtrace snipped

# I can change it to the default location, but to no avail
05:57:54 ruerue@purr> nano -w .gemrc

06:00:36 ruerue@purr> cat .gemrc
gem: --gen-rdoc --run-tests
rdoc: --all --line-numbers --inline-source
gemhome: /usr/lib/ruby/site_ruby/1.8/rubygems
gempath:
- /usr/lib/ruby/site_ruby/1.8/rubygems

06:00:39 ruerue@purr> gem install -r og
Attempting remote installation of 'og'
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:131:in `activate': (Gem::LoadError)
Could not find RubyGem sources (> 0.0.0)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:34:in `require_gem'
# ...

# Removing it works, though
06:00:48 ruerue@purr> nano -w .gemrc

06:04:11 ruerue@purr> cat .gemrc
gem: --gen-rdoc --run-tests
rdoc: --all --line-numbers --inline-source
gempath:
- /usr/lib/ruby/site_ruby/1.8/rubygems

06:04:15 ruerue@purr> gem install -r og
Attempting remote installation of 'og'
Install required dependency extensions? [Yn]
 
J

Jim Weirich

On my system, anything in the gemhome field in .gemrc seems to render
Gems unusable.

The reason it is failing is that gems requires a "sources" gem be available to
tell it where to the sites to use to get remote gems. You can work around
this by putting the standard gem repository in the gem path, while leaving
the new gemhome be the target for new installations.

Here's what worked for me on my linux system.

First, with an unmodified .gemrc file, find the directory of the current gem
home:

$ gem env gemdir
/usr/local/lib/ruby/gems/1.8

Now edit .gemrc to contain ...

gem: --gen-rdoc --run-tests
rdoc: --all --line-numbers --inline-source
gemhome: /home/ruerue/lib/ruby
gempath:
- /usr/local/lib/ruby/gems/1.8

Now the .gemrc file will direct all new installations to
the /home/ruerue/lib/ruby directory.

It would be nice to have a way of initializing a new gem home directory with
the sources package. Then you wouldn't need to have the original gem
directory in the gem path. I suppose you could do it by hand, but I haven't
tried it.
 
E

ES

Jim said:
The reason it is failing is that gems requires a "sources" gem be available to
tell it where to the sites to use to get remote gems. You can work around
this by putting the standard gem repository in the gem path, while leaving
the new gemhome be the target for new installations.

Here's what worked for me on my linux system.

First, with an unmodified .gemrc file, find the directory of the current gem
home:

$ gem env gemdir
/usr/local/lib/ruby/gems/1.8

Now edit .gemrc to contain ...

gem: --gen-rdoc --run-tests
rdoc: --all --line-numbers --inline-source
gemhome: /home/ruerue/lib/ruby
gempath:
- /usr/local/lib/ruby/gems/1.8

Now the .gemrc file will direct all new installations to
the /home/ruerue/lib/ruby directory.

Thanks for the idea! I had tried it already, though, but no luck. I'm
thinking it's probably got something to do with how Gentoo packages
RubyGems. I'll look into it. In the meanwhile I'm using --install-dir
and put my library path in gempath instead.
It would be nice to have a way of initializing a new gem home directory with
the sources package. Then you wouldn't need to have the original gem
directory in the gem path. I suppose you could do it by hand, but I haven't
tried it.

Maybe you can just separate RUBYGEMS_HOME from GEM_HOME?

E
 

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

Forum statistics

Threads
473,787
Messages
2,569,629
Members
45,332
Latest member
LeesaButts

Latest Threads

Top