zycte
6/16/2006 1:41:00 PM
The require statements in the "all_libs" file are loaded relative to
$LOAD_PATH. This is an array consisting of your ruby library
directories and the 'current' directory (output of pwd when you
launched ruby).
When you load the file in "folder1", the require statements in
"all_libs" are considered relative to "folder1". So if "all libs"
contains the line "require 'somefile' ", then ruby will look for
"somefile" in "folder1", and not find it.
You can solve this by adding the following line in a file in folder1
and folder2:
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "libraries")
This adds the "libraries" folder to the load path. Now you can require
"all_libs" without trouble.
On 2006-06-16 11:32:16 +0200, "aidy" <aidy.rutter@gmail.com> said:
> Hi,
>
> I have a number of a directories on a server: e.g
>
> \\server\ruby\watir
>
> folder1, folder2, libraries #at the same level
>
>
> I would like file1 and file2 to see the libraries folder.
>
> I have tried entering this:
>
> require '../libraries/all_libs' #all_libs is an .rb file
> in a Ruby file in folder1 without success.
> Thanks
>
> Aidy