Hi,
In message "[ruby-talk:5405] Path for requires statements"
on 00/10/11, "Chris Morris" <chrismo / homemail.com> writes:
|Newbie alert: ruby can't find the file I'm referring to in a require
|statement. The file required is in the same directory as the original source
|file. Obviously, this doesn't work. Where does ruby get its path info?
See the variable $LOAD_PATH. For my case:
% ruby -e 'p $LOAD_PATH'
["/usr/local/lib/site_ruby/1.6/i586-linux", "/usr/local/lib/site_ruby/1.6", "/usr/local/lib/site_ruby", "/usr/lib/ruby/1.6/i586-linux", "/usr/lib/ruby/1.6", "."]
If you want to load files from the directory where the original file
is, the following technique may work:
$LOAD_PATH.unshift File::dirname($0)
require 'the_file_you_want_to_load'
matz.