pub fn find_with_cargo_home(exec: &str) -> Option<Utf8PathBuf>Expand description
find_with_cargo_home return a PathBuf for the given executable, it tries to find it in PATH, environment variables and CARGO_HOME.
The current implementation checks three places for an executable to use:
- $PATH/
<executable_name>example: for cargo, this tries all paths in $PATH with appendedcargo, returning the first that exists - Appropriate environment variable (erroring if this is set but not a usable executable) example: for cargo, this checks $CARGO environment variable; for rustc, $RUSTC; etc
$CARGO_HOME/bin/<executable_name>where $CARGO_HOME defaults to ~/.cargo (see https://doc.rust-lang.org/cargo/guide/cargo-home.html) example: for cargo, this tries $CARGO_HOME/bin/cargo, or ~/.cargo/bin/cargo if $CARGO_HOME is unset. It seems that this is a reasonable place to try for cargo, rustc, and rustup