ITADN

Add the ability to ignore duplicate (multiple) crate versions transitively caused by duplicate crate versions up the dependency tree

#849Open9SMTM6 创建于 2026-04-16
enhancement
9
9SMTM6commented
**Is your feature request related to a problem? Please describe.** One of my projects has sadly 5 versions of `windows-sys` (sadly not uncommon for OS centric -sys crates). But that doesn't just cause the duplicate warning for `windows-sys`, but also for some of its dependencies that are set to incompatible versions, like `windows-targets`, `windows_x86_64_gnullvm` and the list goes on. Now, unless these are also caused by other sources, these duplicates will obviously go away if the source duplicate versions are unified. So these transitive duplicates are not really directly actionable, or at least should probably not be directly acted upon. Meanwhile the warnings caused by these transitive duplicates bloat your warnings and make it less clear what the actual issue is, and need a lot of manual cleanup after the fact to determine root causes. At that point its not much different from just greping the cargo.lock file for duplicates. Its also possible one makes mistakes when trying to eliminate these duplicate duplicate warnings (;-P). So, while it may also be helpful to be able to see the total amount of duplication, and/or the duplication caused by duplicates further up the tree, being able to filter out these purely transitive duplicates would make things much clearer in projects with lots of dependencies (which is sadly the norm in many internet connected projects these days). If not including `--hide-inclusion-graph`, the output of cargo deny even exceeds the scrollback in some of my terminals **Describe the solution you'd like** Maybe just adding this as a flag similar to `--hide-inclusion-graph` is better, otherwise you can't easily switch between views. That flag should filter out duplicates transitively (and exclusively!) caused by duplicates from up inclusion graph. Additionally, a feature that might also be helpful, is to be able to view the amount of duplication caused by these root duplicates in some way, but that's of course not required. **Describe alternatives you've considered** As stated above, manually filtering out these transitive duplicates can be a lot of work and error prone in projects with lots of dependencies, especially if they freshly adopt cargo deny. **Additional context** I can understand if this feature request is difficult to address. Its probably at least not trivial to solve. I just found that this was not previously reported, and I found nothing else on this, so I thought I'd do the honors. Despite using similar terms, this issue is very distinct from https://github.com/EmbarkStudios/cargo-deny/issues/662. That issue wants to suppress, amongst others, duplicate crate versions caused by one (!) transitive dependency at a time, and all of them, so e.g. the example I gave above would not lead to any warnings, since I don't directly depend on different versions of `windows-sys`. This issue wants to suppress only duplicate crate versions caused by duplicate (!) dependencies further up the dependency tree.
1 条评论