I want to manage the way how Ruby searches modules to load. I found,
that the $: variable is in charge, but it is read-only. Then I found
that RUBYLIB can be used to add directories.
As I have c:/PJ/lib and c:/PJ/test for my Windows souces I entered via
irb
RUBYLIB = [“c:/PJ/lib”, “c:/PJ/test”] using the same Unix-style ("/"
instead of “”) as I saw in $:
When entered ‘load “simple.rb”’ I got “no such file to load”.
How can I set RUBYLIB, or other variable to control the Ruby search?
I want to manage the way how Ruby searches modules to load. I found,
that the $: variable is in charge, but it is read-only. Then I found
that RUBYLIB can be used to add directories.
The variable is read only, but the object that it refers to (an
array of strings) is not frozen. You can modify the object:
irb(main):001:0> $: = 5
NameError: $: is a read-only variable
from (irb):1
irb(main):002:0> $:.unshift “.”
=> [".", “/usr/local/lib/ruby/site_ruby/1.8”,
“/usr/local/lib/ruby/site_ruby/1.8/i686-linux”,
“/usr/local/lib/ruby/site_ruby”, “/usr/local/lib/ruby/1.8”,
“/usr/local/lib/ruby/1.8/i686-linux”, “.”]
Or you can use RUBYLIB to set $: for newly started ruby processes.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.