From: Erik Veenstra Date: 2005-02-05T06:20:15+09:00 Subject: Re: [BUG] RubyGems: "No such file to load -- rubygems/builder" > > I added some debug information to the require method as > > defined by RubyGems, because I didn't trust a message I got > > ("No such file to load -- rubygems/builder"). > > > > The problem occurs when require is invoked recursively. In > > the situation that a LoadError is thrown some levels deep, > > the file it complains about ("rubygems/builder") isn't the > > file that raised the exception ("yaml", because it's the > > first "9"-line). After installing "libyaml-ruby", I got one > > step further: "zlib" is missing", and so on. But in all > > situations, I got the same message ("No such file to load > > -- rubygems/builder"). > > This is a bug, and I'm not sure the best way to handle this > -- but the real problem is the way that Debian-family Linuxes > package Ruby. I disagree. This example is a result of the strange Ruby packages on Debian systems. That's true. But the same problem can occur in other situations as well. The way the require method of RubyGems catches the LoadError exception is the real problem. The solution is really easy... See below. You can use solution B or C. gegroet, Erik V. ---------------------------------------------------------------- $ cat a.rb class LoadError end module Kernel alias require__ require def require(path) require__ path rescue LoadError => e begin if false # No gem found. else #raise LoadError, "No such file to load -- #{path}" # A #raise e # B raise LoadError, e.message # C end end end end puts "A1" require "b" puts "A2" $ cat b.rb puts "B1" require "c" puts "B2" $ cat c.rb puts "C1" require "d" # Doesn't exist. puts "C2" $ ruby a.rb A1 B1 C1 a.rb:15:in `require': No such file to load -- d (LoadError) from a.rb:22 ----------------------------------------------------------------