-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[diagnostics] Errors for failure to parse a manifest in a git dependency are lost #6211
Comments
Thanks for the report! I agree it is pretty minimal, what more information would make it more helpful! |
I would imagine in this case it could say something like:
Right now it seems to consider parsing a Cargo.toml as a pure pass/fail, and if it fails it is ignored. There probably should be more nuance ("found what you're looking for, but there is a problem"). |
I would imagine in this case it could say something like:
[...]
Right now it seems to consider parsing a Cargo.toml as a pure pass/fail, and if it fails it is ignored. There probably should be more nuance ("found what you're looking for, but there is a problem").
Well, actually when downloading the crate from crates.io, it doesn't
fail the same way (sorry for not having mentioned it in the bug report,
it was in my head but I didn't think of writing it while following the
sections). It already includes the error report.
Now, in crates.io there's a single Cargo.toml, while on such a git dep
on a workspace there are multiple Cargo.toml to consider, so it's maybe
harder to do?
|
So looking at it closer, it looks like this is a special case where just one
The code here will only report the errors if every manifest fails. That might be tricky to fix, because it intentionally ignores manifests it can't parse. I'm not sure the best way to deal with it. One idea is to maybe print warnings for manifests that fail to parse, but that might be very noisy. Perhaps @alexcrichton has ideas? |
I think ideally (not considering implementation complexity, I haven't
checked the code), the code would:
* Check each manifest one by one:
* As soon as a manifest parses and matches, accept it
* If a manifest doesn't parse, record an error
* If no manifest matched, output the generated errors as hints
|
Here is a test in cargo's testsuite that demonstrates this problem: #[cargo_test]
fn shows_error_for_bad_manifest() {
// Checks for an error when a git dependency has multiple manifests, and the one you want fails to load.
let git_project = git::new("git_proj", |project| {
project
.file(
"git1/Cargo.toml",
r#"
[package]
name = "git1"
version = "0.1.0"
this syntax is not valid
"#,
)
.file("git1/src/lib.rs", "")
.file("git2/Cargo.toml", &basic_lib_manifest("git2"))
.file("git2/src/lib.rs", "")
});
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies.git1]
git = '{}'
"#,
git_project.url()
),
)
.file("src/lib.rs", "")
.build();
p.cargo("check")
.with_status(101)
// FIXME: This error message is not very good. It loses the error from parsing git1.
.with_stderr(
"\
[UPDATING] git repository [..]
error: no matching package found
searched package name: `git1`
perhaps you meant: git2
location searched: file:///[..]
required by package `foo v0.1.0 [..]`
",
)
.run();
} Somehow, |
As part of our diagnostic work, I've been wanting to make manifest parsing use "error recovery", meaning the return type could be something like |
Disclaimer: this has been tested only for
cargo 1.26.0 (0e7c5a931 2018-04-06)
, I don't have another cargo at hand right now.Problem
The error message is unhelpful: it only says that the crate wasn't found:
Steps
Have this in a manifest on cargo stable:
Possible Solution(s)
Improve the error message
Notes
Output of
cargo version
:The text was updated successfully, but these errors were encountered: