Function home::rustup_home
source · [−]Expand description
Returns the storage directory used by rustup, often knowns as
.rustup
or RUSTUP_HOME
.
It returns one of the following values, in this order of preference:
- The value of the
RUSTUP_HOME
environment variable, if it is an absolute path. - The value of the current working directory joined with the value
of the
RUSTUP_HOME
environment variable, ifRUSTUP_HOME
is a relative directory. - The
.rustup
directory in the user’s home directory, as reported by thehome_dir
function.
As a matter of backwards compatibility, this function may return
the .multirust
directory in the user’s home directory, only if
it determines that the user is running an old version of rustup
where that is necessary.
Errors
This function fails if it fails to retrieve the current directory, or if the home directory cannot be determined.
Examples
match home::rustup_home() {
Ok(path) => println!("{}", path.display()),
Err(err) => eprintln!("Cannot get your rustup home dir: {:?}", err),
}