Question

I understand that to add a path to $LOAD_PATH just do

$LOAD_PATH.unshift(path)

But I have to add this line to every program I wrote. Is there anyway to add it to the system level?

I tried to search a bit on the startup script for Ruby, but did not find the answer. I tried to add this line to kernel/common/module.rb, ruby_constants.rb, loader.rb,etc. but neither works.

In which file should I add this line to?


Updates:

I am using ubuntu 10.04 and Rubinius. There is no system variable called RUBYLIB.

Tried creating one but did not work. But I realize I made a mistake, and forgot to add the variable in bash script .bashrc. After adding the variable, it all works fine!

Was it helpful?

Solution

RUBYLIB environment variable is a colon separated list of paths which ruby will prepend the the standard LOAD_PATH. ruby -I path on the command line is also the same as $LOAD_PATH.unshift 'path' in your code. Ruby will also process options from environment var RUBYOPT.

OTHER TIPS

$ export RUBYLIB=/tmp/test
$ irb
ruby-1.9.2-p290 :001 > puts $LOAD_PATH
/tmp/test
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top