Skip to content
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

Add a way to check for duplicate dependencies #7285

Open
gnzlbg opened this issue Aug 22, 2019 · 5 comments
Open

Add a way to check for duplicate dependencies #7285

gnzlbg opened this issue Aug 22, 2019 · 5 comments
Labels
A-dependency-resolution Area: dependency resolution and the resolver A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Aug 22, 2019

There should be a simple way to check that there aren't any duplicate dependencies in the dependency graph, e.g., a cargo build --unique-deps / cargo run --unique-deps that errors if two versions of a dependency are anywhere in the dependency graph.

This would be useful for usage in CI.

What I currently do, is manually use cargo tree to pretty print the whole dependency tree, and manually inspect the dependencies. There should be a better way.

@gnzlbg gnzlbg added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Aug 22, 2019
@est31
Copy link
Member

est31 commented Aug 24, 2019

@RalfJung has used Cargo.lock for doing this but the upcoming format doesn't lend itself as nicely to detection of dupes and it was suggested by to use tooling for this instead: #7070 (comment)

It would also be very helpful if you could specify a whitelist of crates that are allowed to be duplicate. Sometimes it requires major effort to deduplicate a dependency. I think servo might only switch to the builtin tool if you can specify a whitelist.

cc @Eijebong

@Eijebong
Copy link
Contributor

Yeah, it's really really hard to go for 0 dupes. (try to have only one version of rand_core if you've got anything depending on rand or one version of winapi if you've got anything depending on mio...).

A whitelist is needed but at least makes people aware of the fact they're duping something. It's useless without a committed lockfile though and that's something to keep in mind.

@Aaron1011
Copy link
Member

@gnzlbg: You can use cargo tree -d to only print duplicates.

@repi
Copy link

repi commented Sep 12, 2019

We created cargo-deny specifically to disallow duplicates by default and manage which duplicates to allow. This we run on CI to verify and uphold and after doing a cargo update or adding crates

@epage epage added A-lints-table Area: [lints] table A-dependency-resolution Area: dependency resolution and the resolver labels Nov 2, 2023
@epage
Copy link
Contributor

epage commented Nov 2, 2023

I'd love for us to look into moving some of cargo-denys functionality into cargo (or cargo-clippy) once we have #12235.

@epage epage added S-triage Status: This issue is waiting on initial triage. A-diagnostics Area: Error and warning messages generated by Cargo itself. and removed A-lints-table Area: [lints] table labels Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

6 participants