I would like to run ruby programs from anywhere. I think I have understood it is RUBYLIB. But I can't make it work. Could you give examples ?
Thx JC
I would like to run ruby programs from anywhere. I think I have understood it is RUBYLIB. But I can't make it work. Could you give examples ?
Thx JC
There is an option -S which looks for the script using PATH environment variable.
for example doing:
ruby -S some_script
Will look for the some_script in current operating system PATH environment variable.
Update: If your script requires other files then use the following statement:
require File.join(File.dirname(__FILE__), "name_of_required_file")
instead of:
require "name_of_required_path"
$LOAD_PATH ($:)
-I directories
(Directories are separated by a :
on Unix-like systems and by a ;
on DOS/Windows systems.)-I
switches to RUBYOPT
($SAFE
must be 0)RUBYLIB
($SAFE
must be 0 also) which contains search paths.RUBYPATH
also changes search path for Ruby programs.$SAFE
setting. If you don't know about it, then its probably fine.I allways set RUBYLIB
and RUBYPATH
to my loadpath and add the -S
option to the interpreter call.