Skip to content

cargo add should not silently remove any path attribute on dependencies and should support both version and path attributes #14510

Open
@rnza0u

Description

@rnza0u

Problem

Cargo supports having both version and path attributes for dependencies declared in Cargo.toml.

When using cargo add [email protected], any path attribute on the crate is getting silently removed.

Also, providing both a remote crate and a path attribute (like cargo add [email protected] --path some/path) is not supported.

Proposed Solution

Cargo should not remove the path attribute on the dependency when using cargo add [email protected].

Also, providing both a remote and a path option at the same time should be supported, since Cargo supports having both in Cargo.toml.

I believe it used to be supported by cargo-edit (see in this examples section https://crates.io/crates/cargo-edit-9).

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-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions