diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index d00c5e47e1c..9a2d5920a74 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -645,7 +645,13 @@ impl<'cfg> Workspace<'cfg> { }; for path in &members_paths { - self.find_path_deps(&path.join("Cargo.toml"), &root_manifest_path, false)?; + self.find_path_deps(&path.join("Cargo.toml"), &root_manifest_path, false) + .with_context(|| { + format!( + "failed to load manifest for workspace member `{}`", + path.display() + ) + })?; } if let Some(default) = default_members_paths { @@ -719,14 +725,15 @@ impl<'cfg> Workspace<'cfg> { self.member_ids.insert(pkg.package_id()); pkg.dependencies() .iter() - .map(|d| d.source_id()) - .filter(|d| d.is_path()) - .filter_map(|d| d.url().to_file_path().ok()) - .map(|p| p.join("Cargo.toml")) + .map(|d| (d.source_id(), d.package_name())) + .filter(|(s, _)| s.is_path()) + .filter_map(|(s, n)| s.url().to_file_path().ok().map(|p| (p, n))) + .map(|(p, n)| (p.join("Cargo.toml"), n)) .collect::>() }; - for candidate in candidates { - self.find_path_deps(&candidate, root_manifest, true) + for (path, name) in candidates { + self.find_path_deps(&path, root_manifest, true) + .with_context(|| format!("failed to load manifest for dependency `{}`", name)) .map_err(|err| ManifestError::new(err, manifest_path.clone()))?; } Ok(()) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index ace60d77f83..777c6d13af5 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -408,7 +408,10 @@ fn invalid_members() { .with_status(101) .with_stderr( "\ -error: failed to read `[..]Cargo.toml` +[ERROR] failed to load manifest for workspace member `[..]/foo` + +Caused by: + failed to read `[..]foo/foo/Cargo.toml` Caused by: [..] @@ -1869,7 +1872,10 @@ fn glob_syntax_invalid_members() { .with_status(101) .with_stderr( "\ -error: failed to read `[..]Cargo.toml` +[ERROR] failed to load manifest for workspace member `[..]/crates/bar` + +Caused by: + failed to read `[..]foo/crates/bar/Cargo.toml` Caused by: [..] @@ -2318,6 +2324,55 @@ Caused by: .run(); } +#[cargo_test] +fn member_dep_missing() { + // Make sure errors are not suppressed with -q. + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file( + "bar/Cargo.toml", + r#" + [project] + name = "bar" + version = "0.1.0" + + [dependencies] + baz = { path = "baz" } + "#, + ) + .file("bar/src/main.rs", "fn main() {}") + .build(); + + p.cargo("build -q") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to load manifest for workspace member `[..]/bar` + +Caused by: + failed to load manifest for dependency `baz` + +Caused by: + failed to read `[..]foo/bar/baz/Cargo.toml` + +Caused by: + [..] +", + ) + .run(); +} + #[cargo_test] fn simple_primary_package_env_var() { let is_primary_package = r#"