You can access operating system environment variables using
the predefined variable
ENV
. It responds to the same
methods as
Hash
.
[ENV
is not actually a hash, but
if you need to, you can convert it into a Hash
using
ENV#to_hash
.]
The values of some environment variables are read by Ruby
when it first starts. These variables modify the behavior of the interpreter,
as shown in Table 13.1 on page 139.
Environment variables used by Ruby
Variable Name
|
Description
|
RUBYOPT
|
Additional command-line options to Ruby; examined after
real command-line options are parsed ($SAFE
must be 0). |
RUBYLIB
|
Additional search path for Ruby programs
($SAFE must be 0). |
RUBYPATH
|
With -S option, search path for Ruby
programs (defaults to PATH ). |
RUBYSHELL
|
Shell to use when spawning a process; if not
set, will also check SHELL or COMSPEC . |
DLN_LIBRARY_PATH
|
Search path for dynamically loaded
modules. |
RUBYLIB_PREFIX
|
(Windows only) Mangle the RUBYLIB search path by
adding this prefix to each component. |
|
|