From: Stefan Lang Date: 2005-11-05T08:06:11+09:00 Subject: Re: Setting RUBYLIB On Friday 04 November 2005 21:19, Stu Glaser wrote: > Hi, > > I currently have a project with two files. I want to include one > file from the other without specifying the entire path. Here's > what I'm trying to do: > > File: ./app/control/first.rb > puts "HELLO" > > File: ./main.rb > ENV['RUBYLIB'] = "./app" > require 'control/first.rb' > > However, it refuses to find the script ('require': No such file to > load -- control/first.rb) > > When I set RUBYLIB from the (bash) shell, the program runs > correctly. How can I set it inside the main ruby program? The RUBYLIB environment variable is read by the ruby interpreter only at startup. Use this: $LOAD_PATH.unshift "app" require .... More robust would be to use an absolute path: $LOAD_PATH.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "app")) require ... HTH, Stefan