cargo: warning: skipping duplicate package `case` found at `~\.cargo\git\checkouts\cargo-..`
Problem
When using cargo install --git to install a package like cargo itself, a lot of warnings are emitted about duplicated packages. It seems that these packages are only used for the tests, and not sure if the warnings affect the final build.
warning: skipping duplicate package `cargo-list-test-fixture` found at `~\.cargo\git\checkouts\cargo-..`
...
It seems that this is caused by this commit: https://github.com/rust-lang/cargo/commit/e903f7dfc0e50fe3e11dcbc5456094c902fce6ce

Steps
Try to build cargo with itself:
cargo install --git https://github.com/rust-lang/cargo
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.63.0-nightly (38472bc19 2022-05-31)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 18 (16 by maintainers)
Commits related to this issue
- Auto merge of #10767 - danilhendrasr:master, r=epage Restrict duplicate deps warning only to published packages Fixes #10752 — committed to rust-lang/cargo by bors 2 years ago
- Auto merge of #9216 - smoelius:master, r=flip1995 Add `ui_cargo_toml_metadata` test This PR adds a test to check the metadata of packages in the `ui_cargo` directory. A recent change to Cargo cause... — committed to rust-lang/rust-clippy by bors 2 years ago
- Avoid 'duplicate package' warnings when depending on cbindgen via git When specifying `cbindgen` as a dependency via git, several 'skipping duplicate package' warnings pop up regarding some of the te... — committed to irh/cbindgen by irh a year ago
- Avoid 'duplicate package' warnings when depending on cbindgen via git When specifying `cbindgen` as a dependency via git, several 'skipping duplicate package' warnings pop up regarding some of the te... — committed to irh/cbindgen by irh a year ago
- Avoid 'duplicate package' warnings when depending on cbindgen via git When specifying `cbindgen` as a dependency via git, several 'skipping duplicate package' warnings pop up regarding some of the te... — committed to irh/cbindgen by irh a year ago
- Avoid 'duplicate package' warnings when depending on cbindgen via git When specifying `cbindgen` as a dependency via git, several 'skipping duplicate package' warnings pop up regarding some of the te... — committed to irh/cbindgen by irh a year ago
- Avoid 'duplicate package' warnings when depending on cbindgen via git When specifying `cbindgen` as a dependency via git, several 'skipping duplicate package' warnings pop up regarding some of the te... — committed to mozilla/cbindgen by irh a year ago
Yes, I thought about that too! It does however seem a bit beyond my acceptability knowledge and the current issue’s specific topic: to discuss separately?
@PaulDance https://github.com/rust-lang/cargo/issues/10147
Would it be possible to restrict the warning to situations where the package is actually used? That is, when doing
cargo install --gitor having a git dependency, only issue a warning if that package was actually part of the selected packages? I suspect that won’t be easy sinceread_packagesis pretty low-level, but I think from a user experience, that is what would be expected. Warning about unrelated packages seems to be a false-positive. Also, forcing people to use a workaround likepublish=falsedoes not seem ideal.I would also expect this to actually be an error in the long-run. In the original issue (#10669), this leads to non-deterministic behavior. A warning just says “something’s broken” and then proceeds doing something random, which doesn’t seem good.
Also, the current warning does not seem to be very helpful (particularly for an end-user who may have no idea where this is coming from, or is not well-versed in cargo). There is no actionable advice given to the user, or any context as to how cargo got into this bind. I would expect in the situation with a git dependency that has a duplicate, it would say something like:
With similar errors for
pathsoverrides andinstall --git.(Without the ability to restrict a git repo to a specific path, the solution of being unique isn’t great, but should be fine in most situations.)
We discussed this in the cargo team meeting and came up with a short term and long-term idea
Short term is to see if we can make the warning only appear when the package is
publish = trueThere is still the wider problem if packages being looked up that are internal. Ideas