I’m setting up on a textdrive shared host, and have installed my gems
to a local directory called ‘gems’. I did this by installing the gems
on my ubuntu 7.04 system and tar’ing up the ‘gems’ to a like-named
directory on the ‘gilford’ (FreeBSD 5.3) shared host. (a trick
required because ‘gem update’ or ‘gem install’ busts txd’s memory
limit during a zlib inflate of the gem repository hash - that is,
memory allocation fails for even the smallest of gems)
After setting my GEM_PATH and GEM_HOME so that ‘gem query’ reports
only my locally installed gems (as expected), and this test:
[xxx@gilford ~]$ gem list rubygems
*** LOCAL GEMS ***
rubygems-update (0.9.2)
RubyGems Update GEM
reports exactly what I expect, I next try ‘gem env’, which nonetheless
reports a back-rev gem version( ! ):
[xxx@gilford ~/local]$ gem env
Rubygems Environment:
- VERSION: 0.8.11 (0.8.11)
- INSTALLATION DIRECTORY: /users/home/xxx/gems
- GEM PATH:
- /users/home/xxx/gems
- /users/home/xxx/local/lib/ruby/site_ruby/1.8
- REMOTE SOURCES:
(note that I have removed the ‘gilford’ system’s gem path altogether,
in desperation. I’m trying to avoid all of txd’s gems, so that I am
certain that only my local stuff is included)
So I download the rubygems-0.9.2.tgz and stick it in a ‘local’
directory, and adjust the two GEM paths above, plus my normal shell
PATH and LD_LIBRARY_PATH to use the ‘local’ bins and libs first. But I
still get ‘gem env’ → 0.8.11
The actual ‘gem’ file in the ‘local/bin’ directory is simply some Ruby
that does:
require ‘rubygems’
Gem.manage_gems
with a few more lines. Surely these lines are run with either
GEM_PATH or the .gemrc path? And I think both of these are right:
‘gem query’ proves ‘GEM_PATH’ is working, and the next paragraph
shows .gemrc works as well.
(I also have a consistent .gemrc in my home dir. According to Jim
Weirich’s note from Apr 3 2006, I think I’m doing the right thing:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/187403
In short: “All gems use GEM_PATH, except for ‘gem’, which
uses .gemrc.” This behavior is supported by a test in which I add or
subtract ‘gilford’s’ gem path from my .gemrc: and as expected, my
‘gem env’ output shows only the lines specified in .gemrc.
The reason I care so much about what ‘gem env’ says is because when I
type “rails -v” I get:
/users/home/xxx/gems/bin/rails:15: undefined method `gem’ for
main:Object (NoMethodError)
which various posts say results from running current ‘rails’ with a
back-rev ‘gem’.
The shared host ‘gilford’ is running Ruby 1.8.4