Bug #1773: Gem path doesn't honor user gem?
http://redmine.ruby-lang.org/issues/show/1773

Author: Lin Jen-Shin
Status: Open, Priority: Normal
ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]

Sorry that I don't have much time to investigate it or
find out if this is fixed in trunk, please tell me if this
is duplicated or fixed, or I need to provide more
information about it.

The problem is that I use only user's gem path
instead of system's gem path. There's no gem
in system's gem path (i.e. /usr/lib/ruby19/gems/1.9.1)

I know that setting $GEM_HOME could resolve this,
but this would be hard to setup correctly between versions of Ruby.
using `ENV['GEM_HOME'] = "..."' and `Gem.clear_paths' could
resolve too, but it's not that clear, and Gem.set_home, Gem.set_paths,
Gem.use_paths doesn't work well.

p.s. Anything above and below are fine with:
ruby 1.8.7 (2008-12-21 MBARI 6 on patchlevel 72) [i686-linux]
So I suppose this is a bug.

$ gem which rack
(checking gem rack-1.0.0 for rack)
/home/photos/.gem/ruby/1.9.1/gems/rack-1.0.0/lib/rack.rb

$ ruby -ve 'gem "rack"'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]
<internal:gem_prelude>:234:in `push_gem_version_on_load_path': Could not find RubyGem rack (>= 0) (Gem::LoadError)
	from <internal:gem_prelude>:14:in `gem'
	from -e:1:in `<main>'

$ cat .gemrc
#gemhome: /home/photos/.gem/ruby/1.8
#gempath: - /home/photos/.gem/ruby/1.8
#         - /home/photos/.gem/ruby/1.9.1
gem: --no-rdoc --no-ri --user-install --format-executable

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.4
  - RUBY VERSION: 1.9.1 (2009-05-12 patchlevel 129) [i686-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby19/gems/1.9.1
  - RUBYGEMS PREFIX: /usr/lib/ruby19/gems/1.9.1/gems/rubygems-update-1.3.4
  - RUBY EXECUTABLE: /usr/bin/ruby19
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/lib/ruby19/gems/1.9.1
     - /home/photos/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-rdoc --no-ri --user-install --format-executable"
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/

$ ruby -ve 'p Gem.path'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]
["/usr/lib/ruby19/gems/1.9.1"]

Gem.set_paths:
$ ruby -ve 'Gem.set_paths("/home/photos/.gem/ruby/1.9.1"); p Gem.path; gem "rack"'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]
["/home/photos/.gem/ruby/1.9.1", "/usr/lib/ruby19/gems/1.9.1"]
<internal:gem_prelude>:234:in `push_gem_version_on_load_path': Could not find RubyGem rack (>= 0) (Gem::LoadError)
	from <internal:gem_prelude>:14:in `gem'
	from -e:1:in `<main>'

Gem.set_home:
$ ruby -ve 'Gem.set_home("/home/photos/.gem/ruby/1.9.1"); p Gem.path; gem "rack"'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]
["/usr/lib/ruby19/gems/1.9.1"]
<internal:gem_prelude>:234:in `push_gem_version_on_load_path': Could not find RubyGem rack (>= 0) (Gem::LoadError)
	from <internal:gem_prelude>:14:in `gem'
	from -e:1:in `<main>'


Gem.use_paths and calling gem first is fine, but not for require first:
$ ruby -ve 'Gem.use_paths("/home/photos/.gem/ruby/1.9.1"); p Gem.path; gem "rack"'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]
["/home/photos/.gem/ruby/1.9.1"]

$ ruby -ve 'Gem.use_paths("/home/photos/.gem/ruby/1.9.1"); p Gem.path; require "rack"'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]
["/home/photos/.gem/ruby/1.9.1"]
-e:1:in `require': no such file to load -- rack (LoadError)
	from -e:1:in `<main>'

Many thanks for your listening.


----------------------------------------
http://redmine.ruby-lang.org