Skip to content

fix: Set RUSTUP_TOOLCHAIN when loading sysroot workspace #19159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/project-model/src/cargo_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions crates/project-model/src/sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -326,6 +326,7 @@ impl Sysroot {
}

fn load_library_via_cargo(
&self,
library_manifest: ManifestPath,
rust_lib_src_dir: &AbsPathBuf,
cargo_config: &CargoMetadataConfig,
Expand All @@ -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,
&|_| (),
Expand Down