-
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
Unused path dependency patches don't emit warning or show up in lock file on update #12464
Comments
Is this issue that all unused patches aren't detected or only with patches of path dependencies? The title and description mostly sound like all patches except in a place or two so its unclear if this is a more general problem. |
It might just an issue with path dependency patches. I just tried git dependency patches:
and
I'll update the title |
I've also made a slight change to the description, It make it sound like this is a blocker for #12419. |
This could be the reason: This should be recorded in |
Just note that if we decide to make this change, this could cause a churn in version control, as somebody will need to commit a new section of Another approach is we can emit a warning without touching the lockfile at this time. Something like,
@rustbot label +S-needs-design -S-triage +A-patch +A-errors +A-lockfile |
In the toy example, the patch dependency isn't patching anything. I may be wrong, but I think the reason why it shows up in the graph is because the patch dependency is a member of the workspace.
In this comment's example, I created a toy example of a known unused patch with a git dependency and it generated a warning because the resolver marked it as unused.
Good question. The cases where this might happen are probably limited actually: typos or thinking a package is used as a dependency but it isn't so the patch isn't applied. For some context, we fixed an issue where
Probably the easiest is to emit a warning that suggests to remove the patch manually from the toml. Or we can add a flag to |
That's true IIRC. Cargo creates only one dependency graph per cargo invocation for a workspace. That's also why I called out this line of code as a culprit, and consider it has the same root cause as #12471: if !self.graph.contains(&summary.package_id()) { For #12464 (comment) the example, they have different Feel like action items here would be:
|
Problem
While investigating #12419, a solution is to use the
unused_patches
field of theResolve
returned fromresolve_ws
. It turns out this field wasn't being populated for path dependency patches. As a result, an unused patch doesn't emit a warning or show up in the lock file as an unused patch duringcargo update
Steps
Same test case in #12419, but running
cargo update
instead.Current:
No warning and lock file below:
Expectation:
The expectation is if a patch is unused, a warning would be emitted and would show up as a
patch.unused
section in the lock fileThe following warning is emitted:
Cargo file:
Possible Solution(s)
Haven't really looked into how to do it but I think the errant code is here:
cargo/src/cargo/core/resolver/resolve.rs
Lines 142 to 148 in 211fd7e
Notes
No response
Version
The text was updated successfully, but these errors were encountered: