From: ptkwt@... (Phil Tomson) Date: 2004-03-20T06:09:36+09:00 Subject: Re: Can $LOAD_PATH be relative? In article , Jim Menard wrote: >ptkwt@aracnet.com (Phil Tomson) writes: > >> Question based on an assertion made in another thread... >> >> I was under the impression that $LOAD_PATH is relative to the current >> location of the ruby executable. On Windows this certainly seems to be >> the case. I can move ruby.exe and see that $LOAD_PATH changes. >> >> However, on Linux this doesn't seem to be the case, no matter where I put >> the ruby binary, $LOAD_PATH points to /usr/local/lib/ruby/... >> >> Is there anyway to make $LOAD_PATH relative on Linux (and I suspect also >> on Windows if you use MingW to compile) just as it is on the Windows >> mswin32 build? >> >> ...I'm hoping this is just a configure command-line switch since I need to >> put the Ruby binary and some libs on a CDROM and have it execute from >> there. > >You can add to $LOAD_PATH when the script starts, and those paths can be >relative to the script itself. Does that help? For example, > > HERE = File.dirname(__FILE__) # __FILE__ does not alwyas == $0 > $LOAD_PATH << HERE # Add script's directory > $LOAD_PATH << File.join(HERE, '..') # Add directory above script > >Since you are in control of the directory structure on the CD, you should be >able to find the Ruby libs relative to the script. > >You could also use the -I command line switch or the environment variable >RUBYLIB to add to the list of directories to search. > True, I could do those things, but I'm wondering how they managed to make $LOAD_PATH relative on Windows? Phil