mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
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.
This commit is contained in:
parent
312f1fe20a
commit
c4664609ed
2 changed files with 2 additions and 0 deletions
|
@ -215,6 +215,7 @@ impl FlycheckActor {
|
|||
} => {
|
||||
let mut cmd = Command::new(toolchain::cargo());
|
||||
cmd.arg(command);
|
||||
cmd.current_dir(&self.workspace_root);
|
||||
cmd.args(&["--workspace", "--message-format=json", "--manifest-path"])
|
||||
.arg(self.workspace_root.join("Cargo.toml"));
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in a new issue