Skip to content

Commit 049f4db

Browse files
authored
Add warning and debug information when cargo metadata fails
The errors are silently dropped elsewhere, which make it really hard to debug issues due to dependency download failures.
1 parent 5ad05fb commit 049f4db

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,22 @@ impl CargoWorkspace {
288288
locked: bool,
289289
progress: &dyn Fn(String),
290290
) -> anyhow::Result<(cargo_metadata::Metadata, Option<anyhow::Error>)> {
291-
Self::fetch_metadata_(cargo_toml, current_dir, config, sysroot, locked, false, progress)
291+
let res = Self::fetch_metadata_(
292+
cargo_toml,
293+
current_dir,
294+
config,
295+
sysroot,
296+
locked,
297+
false,
298+
progress,
299+
);
300+
if let Ok((_, Some(ref e))) = res {
301+
tracing::warn!(
302+
"`cargo metadata` failed on `{cargo_toml}`, but retry with `--no-deps` succeeded"
303+
);
304+
tracing::debug!("{e:?}");
305+
}
306+
res
292307
}
293308

294309
fn fetch_metadata_(

0 commit comments

Comments
 (0)