1
Fork 0

Set RUSTUP_TOOLCHAIN when loading sysroot workspace

This commit is contained in:
Lukas Wirth 2025-02-16 10:51:58 +01:00
parent 7f8781419c
commit af804d23e2
2 changed files with 6 additions and 2 deletions

View file

@ -277,6 +277,9 @@ impl CargoWorkspace {
/// Fetches the metadata for the given `cargo_toml` manifest.
/// A successful result may contain another metadata error if the initial fetching failed but
/// the `--no-deps` retry succeeded.
///
/// The sysroot is used to set the `RUSTUP_TOOLCHAIN` env var when invoking cargo
/// to ensure that the rustup proxy uses the correct toolchain.
pub fn fetch_metadata(
cargo_toml: &ManifestPath,
current_dir: &AbsPath,

View file

@ -247,7 +247,7 @@ impl Sysroot {
let library_manifest = ManifestPath::try_from(src_root.join("Cargo.toml")).unwrap();
if fs::metadata(&library_manifest).is_ok() {
if let Some(loaded) =
Self::load_library_via_cargo(library_manifest, src_root, cargo_config)
self.load_library_via_cargo(library_manifest, src_root, cargo_config)
{
return Some(loaded);
}
@ -326,6 +326,7 @@ impl Sysroot {
}
fn load_library_via_cargo(
&self,
library_manifest: ManifestPath,
rust_lib_src_dir: &AbsPathBuf,
cargo_config: &CargoMetadataConfig,
@ -342,7 +343,7 @@ impl Sysroot {
&library_manifest,
rust_lib_src_dir,
&cargo_config,
&Sysroot::empty(),
self,
// Make sure we never attempt to write to the sysroot
true,
&|_| (),