From: Alan Davies Date: 2003-03-21T02:58:10+09:00 Subject: Re: Find::Bin, use lib, in ruby I've run into this problem before, i.e. your script is stored in a different location to the current dir, and requires a file from the same directory as itself. I simply put this at the top of my files: $LOAD_PATH << File.dirname(__FILE__.gsub(/\\/, '/')) The gsub is needed on Windows systems because dirname only works with forward slashes (is there any plan to fix this it's a pain). (I also prefer using $LOAD_PATH because I hate all that $: nonsence... its completely unreadable) Alan "ahoward" wrote in message news:Pine.LNX.4.53.0303201609120.1795@eli.fsl.noaa.gov... > On Thu, 20 Mar 2003, Brian Candler wrote: > > > On Thu, Mar 20, 2003 at 03:03:09AM +0900, Daniel Bretoi wrote: > > > rubyscripts/bin/script.rb > > > rubyscripts/lib/libforscript.rb > > > > > > How can I tell script.rb where to look for libforscript.rb without > > > having to use absolute paths? > > > > > > $:.unshift "../lib" > > require "libforscript.rb" > > what if you were in /usr/bin/ while running script.rb? the '../lib' needs to > be relative to the location of script.rb, not the current working directory. > > -a > > -- > ==================================== > | Ara Howard > | NOAA Forecast Systems Laboratory > | Information and Technology Services > | Data Systems Group > | R/FST 325 Broadway > | Boulder, CO 80305-3328 > | Email: ahoward@fsl.noaa.gov > | Phone: 303-497-7238 > | Fax: 303-497-7259 > ====================================