Skip to content

cargo add: Handle paths automatically without requiring --path #14134

Open
@joshtriplett

Description

@joshtriplett

Problem

$ cargo add ../testlib
error: invalid character `.` in package name: `../testlib`, the first character must be a Unicode XID start character (most letters or `_`)

Ideally, when given an argument containing a path separator (which is never valid in a crate name), cargo add could automatically assume --path if the specified path exists as a directory.

If there's a compatibility reason why we can't do that, then at a minimum cargo add could suggest --path. But I think we could reasonably infer that and proceed.

Proposed Solution

When cargo add receives an argument containing a path separator, rather than erroring, cargo add should infer --path and proceed.

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-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions