From: Gary Wright Date: 2009-12-31T03:00:17+09:00 Subject: Re: How to run one script from another, and capture the output On Dec 30, 2009, at 12:24 PM, John Smith wrote: > > However, I should also add that in the above example, > distance_traveled.rb requires other .rb files sitting in the same lib > directory. > > I have no problem running distance_traveled.rb from inside lib. However, > from another directory, when I try to run the program using relative > path (ie. 'ruby ../../lib/distance_traveled.rb'), I get > "distance_traveled.rb:1:in `require': no such file to load -- ", in > reference to the other .rb file(s) in the lib directory. > > Any suggestions for this issue? Thanks again! If the files aren't in standard library locations, you'll want to make sure that you name them relative to the source file using something like: require File.join(File.expand_path(File.dirname(__FILE__)), 'otherfile') This ensures that the require method sees a fully qualified path to 'otherfile' where 'otherfile' is found relative to the directory containing the source file instead of relative to the current working directory of the process. Gary Wright