8

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!

2 Answers 2

10

RUBYLIB environment variable is a colon separated list of paths which ruby will prepend to 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.

Sign up to request clarification or add additional context in comments.

4 Comments

I thought they removed RUBYLIB after 1.9? I am using Rubinius and did not find RUBYLIB. And ruby -I is annoying too
I just double checked. There is no RUBYLIB or RUBYOPT env var. I am using ubuntu 10.04 and Rubinius 2.0. I also tried adding a system variable but it did not work.
@texasbruce maybe you should edit your question to show what you tried, and how it didn't work.
@texasbruce rbx honors RUBYLIB just as MRI rubies do. Here's the source
3
$ export RUBYLIB=/tmp/test $ irb ruby-1.9.2-p290 :001 > puts $LOAD_PATH /tmp/test ... 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.