Skip to content

Proposal: Adding a prune command/flag to the cargo CLI #13234

Open
@coillteoir

Description

@coillteoir

Problem

Dependencies may be left orphaned or unused in a project as it grows and changes. This can increase build times and storage requirements for developer workstations. While it is up to developers to ensure their dependencies are in order, issuing a cargo command to remove these dependencies would be beneficial.

This seems like a common enough use case among developers to integrate it with the Cargo CLI.

Proposed Solution

Implementing a prune command cargo prune --[flags] to automatically mark unused dependencies. Some flags to consider would be a dry-run flag, dev dependencies only, and more.

Notes

Docker has a similar command docker image prune which will remove all unused images in a local registry. docs

Npm has a similar solution. docs

There is an existing solution to this problem. github

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crate-dependenciesArea: [dependencies] of any kindC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions