Revert "prioritise rustup sysroots over system ones"

This reverts commit 9f1d4aa4b9.
This commit is contained in:
Lukas Wirth 2024-03-05 09:37:25 +01:00
parent 0c2e9feaee
commit fe0daa7be3

View file

@ -63,17 +63,21 @@ fn get_path_for_executable(executable_name: &'static str) -> PathBuf {
// The current implementation checks three places for an executable to use: // The current implementation checks three places for an executable to use:
// 1) Appropriate environment variable (erroring if this is set but not a usable executable) // 1) 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 // example: for cargo, this checks $CARGO environment variable; for rustc, $RUSTC; etc
// 2) `$CARGO_HOME/bin/<executable_name>` // 2) `<executable_name>`
// example: for cargo, this tries just `cargo`, which will succeed if `cargo` is on the $PATH
// 3) `$CARGO_HOME/bin/<executable_name>`
// where $CARGO_HOME defaults to ~/.cargo (see https://doc.rust-lang.org/cargo/guide/cargo-home.html) // 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. // 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 // It seems that this is a reasonable place to try for cargo, rustc, and rustup
// 3) `<executable_name>`
// example: for cargo, this tries just `cargo`, which will succeed if `cargo` is on the $PATH
let env_var = executable_name.to_ascii_uppercase(); let env_var = executable_name.to_ascii_uppercase();
if let Some(path) = env::var_os(env_var) { if let Some(path) = env::var_os(env_var) {
return path.into(); return path.into();
} }
if lookup_in_path(executable_name) {
return executable_name.into();
}
if let Some(mut path) = get_cargo_home() { if let Some(mut path) = get_cargo_home() {
path.push("bin"); path.push("bin");
path.push(executable_name); path.push(executable_name);
@ -82,10 +86,6 @@ fn get_path_for_executable(executable_name: &'static str) -> PathBuf {
} }
} }
if lookup_in_path(executable_name) {
return executable_name.into();
}
executable_name.into() executable_name.into()
} }