Add a Gem Path?

Viewed 13265

When I run gem environment I get a list which includes the following:

  • GEM PATHS:
    • /home/rescue/.rvm/rubies/ruby-2.3.3/lib/ruby/gems/2.3.0
    • /home/rescue/.gem/ruby/2.3.0

I'd like to add a path. I see people suggesting to add something like export GEM_PATH = ... to my .bashrc file, but I fear this would replace the existing gem paths.

How can I add another path in addition to the ones that already exist?

3 Answers

I think it is not possible to just add path without override.

Answer your question is in

https://github.com/rubygems/rubygems/blob/master/lib/rubygems.rb#L404

 when 'GEM_HOME', 'GEM_PATH', 'GEM_SPEC_CACHE'
 .... 
 @paths = Gem::PathSupport.new ENV.to_hash.merge(target)

Code is complicated, but you can read that you can set path only by one of these 'GEM_HOME', 'GEM_PATH', 'GEM_SPEC_CACHE' variables.

Then gem put these variables as constructor to Gem::PathSupport where paths are set.

https://github.com/rubygems/rubygems/blob/master/lib/rubygems/path_support.rb

Related