Skip to content

Commit

Permalink
Ignore broken Cargo.toml in git sources
Browse files Browse the repository at this point in the history
Commit 3d6de41 (#3998) made cargo
ignore Cargo.toml files that are invalid TOML in a git source.
This change further ignores Cargo.toml files that are valid TOML but
cannot really be loaded.

This is potentially an alternative fix for #6822.
  • Loading branch information
quark-zju committed Feb 29, 2020
1 parent 62180bf commit a2cddee
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/cargo/ops/cargo_read_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a2cddee

Please sign in to comment.