Hi!
I've thought a bit more about how RubyGems overrides the Ruby require
method and how it deals with LoadErrors and it seems to me that there
is general issue with the contract of the Ruby require method being
changed, and also, and more seriously, of silent failures. Consider
the following example. We have a system with the Rails gem installed
and the file test_helper.rb can be found in that gem. Suppose we have
a file in the current directory called test_helper.rb that only
contains:
require 'b'
where the file b doesn't exist. Then, with RubyGems no exception is
thrown when requiring the test_help.rb file:
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'test_help'
=> false
According to the contract of require this would indicate that
"test_help" has already been loaded, which is true in a sense, but
the load failure is never exposed.
Without RubyGems an exception is thrown on the first invocation of
require, but not the second:
require File.join(File.dirname(__FILE__), "test_help")
LoadError: no such file to load -- b
from ./test_help.rb:1:in `require'
from ./test_help.rb:1
from (irb):1
irb(main):002:0> require File.join(File.dirname(__FILE__), "test_help")
=> false
I hope this illustrates the issue that I am getting at. RubyGems
cannot know that the LoadError exception refers to the path of the
require, it can refer to a nested require. When the second invocation
of __require in RubyGems require method returns false, should
RubyGems maybe issue a warning?
Thanks!
Peter
----------------------------
Peter Marklund
Garvar Lundins Gränd 7
11220 Stockholm
Sweden
Mobile Phone: +46-(0)70-4164857
Home Phone: +46-(0)8-50091315
Skype: peter_marklund
IM: AIM - petermarklund, MSN - [EMAIL PROTECTED], Yahoo -
peter_marklund2002
http://marklunds.com
----------------------------
_______________________________________________
Rubygems-developers mailing list
Rubygems-developers@rubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-developers