Skip to content

cargo add should check public transitive dependencies when auto-picking a version #13038

Open
@epage

Description

@epage

Problem

When adding a new dependency that is meant to interact with another one (ie its a public transitive dependency), you need the versions aligned.

Proposed Solution

When cargo add foo auto-selects the version requirement, we shouldn't just check other dependency tables to see if the dependency is present but we should first check public transitive dependencies of the table we are editing.

We also should check the public dependencies of the package being added to see if there is a better match

ie in the ideal case we would allow either of the following

$ cargo add clap_complete@3
$ cargo add clap  # pick v3 instead of v4
$ ...
$ cargo add clap@3
$ cargo add clap_complete  # pick v3 instead of v4

How well it works in practice, it will be seen.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-addS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewZ-public-dependencyNightly: public-dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions