-
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
[patch] causes cargo run to succeed once, then fail, with no intervening changes #7282
Comments
Thanks for the report, and this definitely sounds confusing! I'm having a tough time minimizing this though without creating a number of github repos. Would you be able to help out in narrowing this down to just a few crates to explore what Cargo's doing here? |
Thanks for looking into this! So I'm afraid I can't reproduce the specific example much more. Every time I try to recreate it, it fails to reproduce exactly. But! I can give you a similar error. I created three crates, base, intermediate, and app. base has no dependencies; intermediate depends on base; and app depends on both intermediate and base. Note that intermediate uses no ".git" suffix to depend on base, while app does use a ".git" suffix to depend on base. If you try to build app,
Note that I didn't do anything crazy to get into this state. The
|
Ok apologies for the excessive delay in getting back to this, but the fix should be posted at #7368. Thanks again for helping me reduce this, that made this much easier to debug, verify a fix, and write a test case! |
Work with canonical URLs in `[patch]` This commit addresses an issue with how the resolver processes `[patch]` annotations in manifests and lock files. Previously the resolver would use the raw `Url` coming out of a manifest, but the rest of resolution, when comparing `SourceId`, uses a canonical form of a `Url` rather than the actual raw `Url`. This ended up causing discrepancies like those found in #7282. To fix the issue all `patch` intermediate storage in the resolver uses a newly-added `CanonicalUrl` type instead of a `Url`. This `CanonicalUrl` is then also used throughout the codebase, and all lookups in the resolver as switched to using `CanonicalUrl` instead of `Url`, which... Closes #7282
Excessive delay?! The fact that you got to this in a few weeks is super impressive, in my opinion. Thanks, @alexcrichton! |
A somewhat pathological [patch] block can cause
cargo run
to succeed once, then fail on subsequent runs with no intervening changes to the crate, for a rather mind-bending experience.Repro instructions:
cargo run
, and watch it succeed:cargo run
and watch it fail:The reason it fails the second time around is because the first run leaves this change to Cargo.lock lying around. Somehow the state that the first patch resolution writes causes the next patch resolution to fail.
Part of the problem here is that the
rust-play
crate depends onhttps://github.com/TimelyDataflow/timely-dataflow.git
(note the ".git" suffix) directly, andhttps://github.com/TimelyDataflow/timely-dataflow
(no ".git" suffix) via differential dataflow. I realize this might seem contrived here, but this actually happened accidentally in a real project, and it was extraordinarily confusing to debug.I guess I don't understand whether it's intended that Cargo can determine when two different URLs actually point to the same crate. In
rust-play
without the[patch]
block, i.e., with this diff appliedCargo somehow figures out that "timely-dataflow.git" and "timely" are actually the same crate, and uses one of them everywhere. The program wouldn't compile otherwise, since the types don't match in a way that causes compilation to fail, because differential exposes its copy of timely in its public API.
If it's intended that Cargo can handle having multiple URLs for the same crate, then it seems like there's just a bug in
[patch]
blocks where this same-crate-different-URL thing isn't getting sorted out. If Cargo isn't supposed to handle having multiple URLs for the same crate... then the situation is more complicated, and I'm not sure what the right fix is.Anyway, I'm out of my depth here, but let me know if I can help at all!
I initially discovered this on macOS with Cargo 1.36, but it seems to reproduce readily with Cargo 1.37.
...actually, I just tried this on master, and it has a totally different presentation. Rather than failing to compile on the second try, it crashes outright:
The panic seems pretty obviously introduced in #7118, though I'm not familiar enough with the code to say whether #7118 moved closer or further to solving this overarching issue.
The text was updated successfully, but these errors were encountered: