-
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 was not used message does not adequately describe reason #8690
Comments
This is a cargo bug, not a rust bug. |
@ehuss could you transfer the issue? |
Transferred. @ryankurte it would be helpful if you could put together an example that doesn't print a helpful error message. Please also include which version of Cargo you are using. The messages were improved recently (#8248), and the example where the patch does not satisfy the dependency requirement should say something like this:
|
oh hey that's super exciting, maybe this is solved (though i am still seeing the old messages on
the current iteration of this is in a non-public project and, (having seen / resolved this many a time prior) i have no idea why the resolution is broken in this case, which is a bit of an impediment to useful reproduction :-( i will try to dig further. |
right, turns out to be a user error when you have a with an the following works, as expected the [dependencies]
log = "0.4.11"
[patch.crates-io]
log = { path = "./log" } This does not work, which, perhaps should be obvious if you read [dependencies]
log = { git = "https://github.com/rust-lang/log" }
[patch.crates-io]
log = { path = "./log" } and this gives you the classic "not used in the crate graph" warning
the correct approach of course is to: [dependencies]
log = { git = "https://github.com/rust-lang/log" }
[patch."https://github.com/rust-lang/log"]
log = { path = "./log" } imo it'd be excellent to have something like:
|
Thanks for digging into that! Yea, that definitely seems like a scenario that could stand to have a better error message. |
Just writing a requirement list would be easier to read in the documentation. Using the example [dependencies]
uuid = "1.0.1"
[patch.crates-io]
uuid = { git = 'https://github.com/uuid-rs/uuid' } or using |
My guess is that also the minor version 1.0.1 is significant, but this is not documented. |
it appears that uuid does not have a version that said, i would suspect the similar situation is because |
I ran into this issue with a slightly different problem, when the major does not match, the patch is ignored. This is not desired behavior as I do not see a way to control the patch apply/ignore logic. |
Related #5640 |
I ran into same probelm I change the package verson and problem solved. |
I bumped into this issue today. How about wording like this?
|
From this code section: cargo/src/cargo/ops/resolve.rs Lines 471 to 488 in 458d345
I feel that "close candidates that failed to match" cannot be simply defined. From my experience, Moreover, since patch-in-config has been stabilized in 1.56, I am afraid that unused patches become more common. That is, more unused patches may lead to a slight performance loss in order to emitting better warnings by querying the graph. Is there any better place or approach to improve this situation? |
@weihanglo There are many reasons why a patch could fail, so I would recommend trying to tackle individual examples instead of going for a general solution. I think the example above about using the wrong source ( Here is an example that does that. That example only works within a single source, so something similar will need to be done inside |
I am afraid that the information from
The The case is awkward and rare, but still valid, and it seems not trivial to me to deal with. Maybe we need to define what are "used patches" and then track them? |
I personally wouldn't worry too much about more unusual situations like that. It would be nice to have the information about the original patch definition, but that may be quite difficult to do (since the unused patches are part of |
Heya, not sure whether we consider usability issues bugs, but, it seemed the closest option.
When configuring
[patch]
es there are a variety of reasons the patch may not be used, resulting in a message like the following:This gives a list of reasons that can be particularly difficult to debug, as well as the recommendation that
cargo update
may help, which is particularly helpful when this message is printed bycargo update
. As an alternative, it would be great to print the specific reason the[patch]
wasn't used, and a proposed resolution, which I believe is in-line with other compiler error improvements.Some possible examples:
Related to: #8400
The text was updated successfully, but these errors were encountered: