Add $ LOAD_PATH from the outside

I understand that to add the path to $ LOAD_PATH just

$LOAD_PATH.unshift(path) 

But I have to add this line to every program I write. Is there any way to add it to the system level?

I tried searching a little while running the script for Ruby, but could not find the answer. I tried adding this line to kernel/common/module.rb , ruby_constants.rb , loader.rb , etc. but does not work.

In which file should this line be added?


Update:

I am using ubuntu 10.04 and Rubinius. The system variable is not called RUBYLIB .

I tried to create one, but did not work. But I understand that I made a mistake, and forgot to add a variable to the bash script .bashrc . After adding the variable, everything works fine!

+6
source share
2 answers

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

+7
source
 $ export RUBYLIB=/tmp/test $ irb ruby-1.9.2-p290 :001 > puts $LOAD_PATH /tmp/test ... 
+2
source

Source: https://habr.com/ru/post/912995/


All Articles