Armed with grep, an investigation into the Ruby source leads to the definition of ruby_initial_load_paths[] in version.c (this is on Ruby 1.9.3). The first of these that apply (neither NO_INITIAL_LOAD_PATH or RUBY_SEARCH_PATH have been set) is RUBY_SITE_LIB2. Looking at the defines above that definition we see:
Following this chain of defines, it becomes clear that this corresponds to the first entry in my load path above. Similarly the other constants that go into this variable correspond to the other load path entries.
The ruby_initial_load_paths[] variable is used in ruby_init_loadpath_safe() in ruby.c, where the actual load path is set up for the process.
So the answer to your question is that the initial load path is set at compile time with some #defines, according to how the build has been configured.
1
Mahmut Bulut
On
Your compilation create a lib directory
on *nix based systems it is generally
/usr/lib/ruby/X.Y.Z
X.Y.Z represents version number of your ruby C api version.
On my machine, the initial load path looks like this:
Armed with
grep
, an investigation into the Ruby source leads to the definition ofruby_initial_load_paths[]
inversion.c
(this is on Ruby 1.9.3). The first of these that apply (neitherNO_INITIAL_LOAD_PATH
orRUBY_SEARCH_PATH
have been set) isRUBY_SITE_LIB2
. Looking at the defines above that definition we see:and in turn:
Following this chain of defines, it becomes clear that this corresponds to the first entry in my load path above. Similarly the other constants that go into this variable correspond to the other load path entries.
The
ruby_initial_load_paths[]
variable is used inruby_init_loadpath_safe()
inruby.c
, where the actual load path is set up for the process.So the answer to your question is that the initial load path is set at compile time with some
#define
s, according to how the build has been configured.