From: Johan Holmberg Date: 2001-12-08T20:46:25+09:00 Subject: [ruby-talk:27918] "load" without looking in $LOAD_PATH ? Hi ! I have an application written in Ruby that needs to read one or more "data/configuration files". I want these files to also be ruby-code, so I'm looking for the "right" way to read these files. At first sight "Kernel#load" seems like the natural choice for this. But Kernet#load doesn't work the way I want. The call load "foo.rb" tries to find the file "foo.rb" somewhere in the path specified by $LOAD_PATH. So if a file with the same name exists "by accident" somewhere in the library path, ruby will never look in my local directory (where the file I want to read usually is located). But couldn't I change $LOAD_PATH, and set it to just "." before calling "load" ??? I guess that would be OK if the loaded "data file" didn't use "require" or "load" by itself. But I want it to be possible for the "data file" to contain arbitrary ruby-code, so this is not really a solution for mee. I have also considered makeing the filename argument "absolute" before passing it to "load". The best way I have found until now is to call "load" like this: load File.expand_path($filename) As far as I can see this effectively disables the path-searching normally done by "load". Is this the right way to do this ??? Or have I missed some better way ??? I'm a little surprised that Ruby doesn't have a function "load_without_looking_in_LOAD_PATH" (but with a better name), ie. a function that finds the file just like an ordinary File#open call does. Then the current "load" function could be a thin wrapper over that function, just adding the searching of LOAD_PATH. Regards, Johan Holmberg