From: Robert Feldt Date: 2001-12-08T22:58:49+09:00 Subject: [ruby-talk:27929] Re: "load" without looking in $LOAD_PATH ? On Sat, 8 Dec 2001, Johan Holmberg wrote: > Yes, but that would just give another twist of undesired behaviour: > > - if the local file was missing, I could still "accidentally" > get a file from somewhere else in the $LOAD_PATH > > - the change would affect further require/load at other places > in other modules. Way to *global*. > > I want the different search-behaviour of "load" to be applied > locally, just for one particular call. > Well, the docs for load says: $ ri Kernel::load ----------------------------------------------------------- Kernel::load load( aFileName, wrap=false ) -> true ------------------------------------------------------------------------ Loads and executes the Ruby program in the file aFileName. If the filename does not resolve to an absolute path, the file is searched for in the library directories listed in $:. If the optional wrap so giving an absolute path is probably the way to go. If you still want to do it by hand then why not: alias old_load load def load(aString, wrap = false, first = false) old_load(aString, wrap) $:.shift if first && ($:.first == ".") end def local_load(aString) $:.unshift "." load(aString, false, true) end and call with local_load "myfile" when you want your behavior. Its not elegant and there are probably better ways but anyway... Regards, RobertF