diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index b331216ca04..35438bfaabb 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -193,7 +193,26 @@ fn read_nested_packages( if !source_id.is_registry() { for p in nested.iter() { let path = util::normalize_path(&path.join(p)); - read_nested_packages(&path, all_packages, source_id, config, visited, errors)?; + let result = + read_nested_packages(&path, all_packages, source_id, config, visited, errors); + // Ignore broken manifests found on git repositories. + // + // A well formed manifest might still fail to load due to reasons + // like referring to a "path" that requires an extra build step. + // + // See https://github.com/rust-lang/cargo/issues/6822. + if let Err(err) = result { + if source_id.is_git() { + info!( + "skipping nested package found at `{}`: {:?}", + path.display(), + &err, + ); + errors.push(err); + } else { + return Err(err); + } + } } } diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 0a75e5b47f3..3a94c93b18d 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -323,6 +323,16 @@ fn cargo_compile_with_malformed_nested_paths() { "#, ) .file("vendor/dep2/Cargo.toml", "!INVALID!") + .file( + "vendor/dep3/Cargo.toml", + r#" + [project] + name = "dep3" + version = "0.5.0" + [dependencies] + subdep1 = { path = "../require-extra-build-step" }"#, + ) + .file("vendor/dep3/src/lib.rs", "") }); let p = project()