[Rubygems-developers] gemloader.rb

Eric Hodel drbrain at segment7.net
Sat Nov 3 11:18:15 EDT 2007

On Nov 2, 2007, at 05:00 , NAKAMURA, Hiroshi wrote:
> Eric Hodel wrote:
>> On Oct 21, 2007, at 18:06 , NAKAMURA, Hiroshi wrote:
>>> NAKAMURA, Hiroshi wrote:
>>>> At the last, I have some questions about rubygems.
>>>> 1. can rubygems/requirement.rb and rubygems/version.rb be free from
>>>>    require 'rubygems'?
>> They are needed for 3.
> Sure.  But they (requirement.rb and version.rb) does not need other
> features, right?  I just mean version.rb.diff can be applied.  Third
> party product may want to use Gem::Requirement and Gem::Version.

Other than module Gem, correct.

>>> 4. rubygems adds spec.bindir to $LOAD_PATH when a gem is activated.
>>> Can't it be a problem when 2 files in bindir and libdir have the  
>>> same
>>> name?  I know it's needed for gem wrapper for a bin script and the
>>> file
>>> in bindir won't be activated by require.
>> require will always try 'foo.rb' or similar, bin path files are
>> loaded with #load, instead.  It is a cheap trick.
>> $ echo 'puts "foo"' > foo
>> $ echo 'puts "foo.rb"' > foo.rb
>> $ ruby -rfoo -e0
>> foo.rb
>> $ ruby -e 'load "foo"'
>> foo
> But if there're bin/foo.rb in bindir and lib/foo.rb in require_path?
> Gem wrapper surely loads foo.rb in bindir because spec.bindir is
> unshifted to $LOAD_PATH.  But 'require "foo"' in a program loads
> 'foo.rb' in bindir I think.  Correct me if I misunderstand something.

Yes, it would, but this has not been a problem in practice.  I think  
it is an acceptable restriction on gem executables.

Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars

More information about the Rubygems-developers mailing list