From: Richard Kilmer Date: 2007-12-27T05:41:49+09:00 Subject: Re: Gem versioning not quite right? This is now fixed in RubyGems trunk and once eric does his magic it will be merged across to 1.9.0. Thanks for finding this. Best, Rich On Dec 26, 2007, at 2:59 PM, Richard Kilmer wrote: > Dave, > > This is, indeed, a bug in rubygems in the code created to get rid of > the require/load hack (gem_prelude.rb) > > The gem_prelude.rb pushes the lib/bin directories of the highest > versioned gems into the $LOAD_PATH on ruby startup. So on my > machine I get: > > ruby -e 'puts $:' > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/actionmailer-2.0.2/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/actionpack-2.0.2/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/activerecord-2.0.2/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/activeresource-2.0.2/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/activesupport-2.0.2/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/builder-2.1.2/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/eventmachine-0.10.0/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/hpricot-0.6/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/rails-2.0.2/bin > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/rails-2.0.2/lib > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/rake-0.8.0/bin > /Users/rich/ruby/lib/ruby/gems/1.9.0/gems/rake-0.8.0/lib > /Users/rich/ruby/lib/ruby/site_ruby/1.9.0 > /Users/rich/ruby/lib/ruby/site_ruby/1.9.0/i686-darwin9.1.0 > /Users/rich/ruby/lib/ruby/site_ruby > /Users/rich/ruby/lib/ruby/vendor_ruby/1.9.0 > /Users/rich/ruby/lib/ruby/vendor_ruby/1.9.0/i686-darwin9.1.0 > /Users/rich/ruby/lib/ruby/vendor_ruby > /Users/rich/ruby/lib/ruby/1.9.0 > /Users/rich/ruby/lib/ruby/1.9.0/i686-darwin9.1.0 > . > > But if I disable "gems" I get: > > ruby --disable-gems -e 'puts $:' > /Users/rich/ruby/lib/ruby/site_ruby/1.9.0 > /Users/rich/ruby/lib/ruby/site_ruby/1.9.0/i686-darwin9.1.0 > /Users/rich/ruby/lib/ruby/site_ruby > /Users/rich/ruby/lib/ruby/vendor_ruby/1.9.0 > /Users/rich/ruby/lib/ruby/vendor_ruby/1.9.0/i686-darwin9.1.0 > /Users/rich/ruby/lib/ruby/vendor_ruby > /Users/rich/ruby/lib/ruby/1.9.0 > /Users/rich/ruby/lib/ruby/1.9.0/i686-darwin9.1.0 > . > > These paths are put on the load path by gem_prelude.rb and it > installs some hooks so If you ever try and do an explicit gem > action, or access a constant in Gem (or a method on Gem) then it > will actually fault in (load) rubygems.rb and run from there. With > your example you did: > > gem 'builder', '< 1' > > This action did in fact fault in Gems (as planned) and push that > gem's lib directory on the $LOAD_PATH, but unfortunately it sticks > it just 'above' the sitelibdir (as does my original code) so the > newly asked for gem's lib directory is after the default loaded one > (2.1.2). This has to be fixed by having data passed from the > gem_prelude code to the rubygems library itself. I will work on > this... > > Sorry about that! > > Best, > > Rich > > On Dec 26, 2007, at 10:10 AM, Dave Thomas wrote: > >> In a fresh sandbox, I installed two versions of the Builder gem: >> >> dave[RUBY3/Book 9:00:56] gem list >> *** LOCAL GEMS *** >> builder (2.1.2, 0.1.1) >> >> Now I run this: >> >> p $:.grep(/builder/) >> gem 'builder', '< 1' >> p $:.grep(/builder/) >> >> and get this: >> >> $ ruby -v t.rb >> ruby 1.9.0 (2007-12-26 revision 0) [i686-darwin8.11.1] >> ["/usr/local/rubybook/lib/ruby/gems/1.9.0/gems/builder-2.1.2/lib"] >> ["/usr/local/rubybook/lib/ruby/gems/1.9.0/gems/builder-2.1.2/lib", >> "/usr/local/rubybook/lib/ruby/gems/1.9.0/gems/builder-0.1.1/lib"] >> >> Note that the 0.1.1 gem is _after_ the 2.1.2 gem in the load path. >> When I subsequently do a "require 'builder'" it loads the latest >> version, and not the version I asked for. >> >> I'm probably misunderstanding something--is this expected? >> >> >> >> Dave >> > >