[Rubygems-developers] require hack

Jim Weirich jim at weirichhouse.org
Thu Mar 25 23:13:00 EST 2004

Simon Strandgaard wrote:
> On Tue, 2004-03-23 at 18:53, Simon Strandgaard wrote:
>>I have made a small hack, so that it no longer is necessary to replace 
> Has anyone tried it out? 
> Is this an ok solution?

I like it.  I have two suggestions ...

(1) Include an extra require, in case the gem in question doesn't have 
an autorequire defined.  That would make the patch ...

module Kernel
   alias old_require require
   def require(filename)
     rescue LoadError
       require(filename)          # Extra require in case there
     end                          # is no auto-require.

(2) Name the file "ubygems.rb".  Then we can invoke it with ...

     ruby -rubygems non_gem_script.rb

-- Jim Weirich    jim at weirichhouse.org     http://onestepback.org
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

More information about the Rubygems-developers mailing list