I want to configure gem to only use system stones - never in $HOME/.gem . This is because I am writing a script that will access the Gem.path , and I do not want it to return the path to the gems in my home directory.
I am sure that I did not explicitly set GEM_HOME or something similar in my .bashrc , .bash_login , etc.
But the Gem.path first returns my homedir gems:
irb > Gem.path => ["/home/nfm/.gem/ruby/1.9.1", "/usr/local/lib/ruby/gems/1.9.1"]
Can i stop this? Where is it set up? Or is it just a default to look at homedir first?
If I cannot configure this, can I return the system path for gems using regexp hackery?
More details:
which ruby /usr/local/bin/ruby ruby --version ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] gem env - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux] - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1 - RUBY EXECUTABLE: /usr/local/bin/ruby - EXECUTABLE DIRECTORY: /usr/local/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /usr/local/lib/ruby/gems/1.9.1 - /home/nfm/.gem/ruby/1.9.1 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http:
Update:
Apparently this can be configured in ~/.gemrc :
However, this does not work if you run irb . This is because the configuration file is YAML, and apparently yaml does not load when irb starts irb (not sure about that!):
$ irb > Gem.path => ["/home/nfm/.gem/ruby/1.9.1", "/usr/local/lib/ruby/gems/1.9.1"] > Gem.configuration.path => ["/usr/local/lib/ruby/gems/1.9.1"]
So, the answer below seems to be the only consistent way to get the right behavior, although you would assume that ~/.gemrc will work and be a more convenient way to configure.
However, the installation :gempath: in my ~/.gemrc worked in the context of the script in my Rakefile in the Rails application, presumably because the jam is explicitly loaded.
Not sure what happens with the jar, but this explanation is similar to what I see here.
Mod up !: P