Merge pull request #19807 from Veykril/lw-qyynkqysuyuy

fix: Don't overwrite `RUSTUP_TOOLCHAIN` if it is already set
This commit is contained in:
Lukas Wirth 2025-05-16 13:21:15 +00:00 committed by GitHub
commit 0843d06ad2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View file

@ -137,7 +137,12 @@ impl Sysroot {
}
let mut cmd = toolchain::command(tool.prefer_proxy(), current_dir, envs);
cmd.env("RUSTUP_TOOLCHAIN", AsRef::<std::path::Path>::as_ref(root));
if !envs.contains_key("RUSTUP_TOOLCHAIN")
&& std::env::var_os("RUSTUP_TOOLCHAIN").is_none()
{
cmd.env("RUSTUP_TOOLCHAIN", AsRef::<std::path::Path>::as_ref(root));
}
cmd
}
_ => toolchain::command(tool.path(), current_dir, envs),