Skip to content

cargo add: update Cargo.lock #10901

@ehuss

Description

@ehuss

Problem

cargo add current does not update Cargo.lock after updating Cargo.toml. That means that the user needs to run some other command to update it. In most cases, this is fine, as most users will then run build or check to use their new dependency. However, some commands do not work (such as cargo pkgid, cargo update -p NEW_DEP, etc.). Additionally, it may be possible that the new dependency doesn't resolve at all (such as a conflict with another dependency).

Proposed Solution

Update Cargo.lock for just the new dependency (essentially, the equivalent of what cargo build and friends do when Cargo.toml changes).

If the update fails, I'm not sure what it should do, but I would lean towards backing out any changes made.

Notes

cargo 1.64.0-nightly (d8d30a753 2022-07-19)

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-add

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions