From: Jim Menard Date: 2004-03-20T05:39:34+09:00 Subject: Re: Can $LOAD_PATH be relative? 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. Jim -- Jim Menard, jimm@io.com, http://www.io.com/~jimm/ "Is 'anal-retentive' hyphenated?" -- Alison Bechdel