From c4664609ed0f8b430285de99b4f7a8cc0ae655f5 Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Wed, 12 May 2021 19:50:52 -0700 Subject: Use package root as `cargo check` working directory Cargo commands are affected by the `.cargo/config` files above their working directory. If cargo is invoked from above the directory holding `Cargo.toml`, it may not pick up important settings like registry replacements, causing it to behave differently or even fail. Most cargo invocations are currently setting their working directories to the directory containing `Cargo.toml`, but a couple of paths remain in which cargo is invoked from the default workspace root instead. This change fixes that, resolving some cargo check failures that I experienced in a multi-root workspace in which packages used different registries. --- crates/project_model/src/build_data.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/project_model') diff --git a/crates/project_model/src/build_data.rs b/crates/project_model/src/build_data.rs index 7b88dca63..3aa546980 100644 --- a/crates/project_model/src/build_data.rs +++ b/crates/project_model/src/build_data.rs @@ -143,6 +143,7 @@ impl WorkspaceBuildData { cmd.env("RA_RUSTC_WRAPPER", "1"); } + cmd.current_dir(cargo_toml.parent().unwrap()); cmd.args(&["check", "--quiet", "--workspace", "--message-format=json", "--manifest-path"]) .arg(cargo_toml.as_ref()); -- cgit v1.2.3