Skip to content

Commit

Permalink
Auto merge of #7947 - quark-zju:ignore-broken-git, r=ehuss
Browse files Browse the repository at this point in the history
Ignore broken Cargo.toml in git sources

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 in a git source.

This is potentially an alternative fix for #6822.
  • Loading branch information
bors committed Mar 2, 2020
2 parents 860d299 + a2cddee commit ac2eb69
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 ac2eb69

Please sign in to comment.