So, under the hook, rvm uses a variety of environment variables to tell it where to locate things. Out of the box, these variables are current:
rvm_path- the directory in which rvm is installed (e.g. typically ~/.rvm)rvm_prefix- basically,${rvm_prefix}rvmis used to build the defaultrvm_path. It tells rvm how to build the defaultrvm_path,rvm_bin_pathandrvm_man_path. This also relies on thervm_sandboxedargumentrvm_sandboxed- tells rvm how to behave when working withrvm_prefix. See "How does rvm_sandboxed work?" below for more information.rvm_bin_path- where rvm puts its executables, where it generates wrappers etc.rvm_man_path- where it places the rvm manpages during install.
rvm_sandboxed is a relatively new addition that instructs rvm how to build up the default values.
Basically, whenever you load rvm it attempts to automatically set a number of variables that let rvm
know where to find scripts, manpages, environments and so on and so forth.
If no variables are set, rvm will attempt to set them to a set of defaults - e.g. for normal users,
$HOME/.rvm or if you're root, /usr/local/rvm. rvm_sandboxed tells rvm how to behave. so, in the
given examples, rvm_prefix will be $HOME/. and /usr/local/ respectively - hence, rvm_path is just
set to the value of ${rvm_prefix}rvm.
When rvm_sandboxed equals 1, it will then set rvm_bin_path to $rvm_path/bin but when it equals 0 it
is set to ${rvm_prefix}bin - this, $HOME/.rvm/bin and /usr/local/bin respectively.
Like wise, when rvm_sandboxed is 1, rvm_man_path is $rvm_path/man but when it is zero it is set to
${rvm_prefix}share/man. In real world use, this typically maps to $HOME/.rvm/man and /usr/local/share/bin.
The idea here being if you set rvm_prefix and rvm_sandboxed, you can tell rvm how to behave in 99% of situations.
Otherwise, you need to manually set multiple variables (e.g. in the old style installs you'd set rvm_path, rvm_bin_path
and rvm_man_path along with rvm_prefix - a system that becomes hard to manage relatively quickly.)
In an attempt to keep compatibility with peoples existing /etc/rvmrc and ~/.rvmrc values, if rvm_sandboxed value is
blank, it will set it by inspecting rvm_path and rvm_bin_path along with a couple of common values.
This makes it incredibly easy for use to deal with it - if, for example, you're installing into a sandbox, you can manually set
rvm_prefix and the like at runtime independently of how they are exposed to the user at runtime (in which case, you'll usually
set them inside /etc/rvmrc so rvm loads them at run time).
So, as part of the rvm install, it loads parts of rvm in order to automatically calculate some of the paths
it needs. In doing so, it should take the user values from rvm_prefix and rvm_sandboxed to work out where
to place it.
By setting it in the environment prior to install, we can give it temporary variables. Then, post-install, we can set them in /etc/rvmrc and rvm will automatically pick them up - the notion being if you're installer has it's own concept of sandbox, just export the env vars before running and then let installer use them to place files.
Because rvm is 'dumb' - e.g. it can't automatically get it's own location (in a cross-shell compatible way), we
rely on using /etc/rvmrc and ~/.rvmrc which rvm automatically loads.