Describe the environment variables present in Ruby.
Environment variables can be directly accessed by using ENV hash. Environment variables can be directly read or written to by using the index operator supplied with a string argument. The child processes of ruby script only are affected by writing ruby environment variables.
Ex:#!/us/bin/envy ruby
# Print some variables
puts ENV['PATH']
puts ENV['EDITOR']
# Change a variable then launch a new program
ENV['EDITOR'] = 'edit'
Environment variables can be set by using
Set TEST=value
Environment Variables Used by Ruby
- RUBYOPT - To add command line switches.
- RUBYPATH - To list the path when used with the -S switch on the command line.
- RUBYPATH will be added to the paths searched when looking for Ruby scripts. The paths in RUBYPATH precede the paths listed in PATH.
- RUBYLIB – The paths list will be added to the path list of Ruby that uses for searching libraries including the program with the require method. The paths in RUBYLIB will be searched before other directories.
Describe the environment variables present in Ruby.
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.