From: Christophe Grandsire Date: 2005-10-28T15:40:45+09:00 Subject: Re: Stuck with modules/classes/inheritance Selon Kev Jackson : > > > > require 'base' > > > > causes > > > > ./lib/b.rb:1:in `require': No such file to load -- base (LoadError) > > from ./lib/b.rb:1 > > from test.rb:1:in `require' > > from test.rb:1 > > > > which is weird as I have done this before with other files, it's just > > this one that it won't find > > > in fact from test.rb, I can require 'lib/base', but from b.rb I can't > require 'base' (with b.rb and base.rb in the same directory) - this is > very strange behaviour > Oops! Of course. "require"'s lookup system bit me again. IIRC it uses $LOAD_PATH, which contains the usual standard lib directory roots, as well as the directory of the file first run by Ruby (AFAIK). It *doesn't* contain the path of library files you may also require. So you have to do require 'lib/base' everywhere. Is there a good reason for this behaviour? There was a RCR to make the require load path relative to the currently executing file (rather than only the originally executing file), but it is branded 'obsolete' and I haven't seen it rewritten, not even in the rejected RCRs. It's currently here: http://www.rcrchive.net/rcr/show/170 Wouldn't it be a good idea to revive it? -- Christophe Grandsire. http://rainbow.conlang.free.fr It takes a straight mind to create a twisted conlang.