william nelson wrote in post #992087:
When you require() a file, ruby looks in some default directories for
the file. You can see which directories are searched by default like
The default directoies that are displayed should also include the
current directory ("."), which is the directory specified in the prompt
next to which your typed the command to run your program:
some_dir/sub_dir> ruby my_program.rb
So if the file you are trying to include is in the current directory, or
one of the default directories, you can require() it.
If the file you are trying to require() is in some other directory, then
you need to either move it into the current directory or one of the
default directories; or you can tell ruby to also search the directory
which contains the file you are trying to require().
There are several ways to accomplish that:
1) Add the directory containing the file you want to require() to the
directories that are searched by default:
$LOAD_PATH << "/some_dir/sub_dir/my_ruby_programs/"
For a more permanent solution, you can also:
2) Add the directory containing the file you want to require, to your
system's PATH environment variable.
3) Create a new environment variable called RUBYPATH, which specifies
additional directories that you want ruby to search.
Posted via http://www.yqcomputer.com/