cargo-remove
Remove dependencies from a Cargo.toml manifest
TLDR
Remove a dependency from the current project
Remove a development or build dependency
Remove a dependency of the given target platform
SYNOPSIS
cargo remove [OPTIONS] [<DEP> ...]
PARAMETERS
-p, --package <SPEC>…
Target package(s) to remove dependencies from (repeatable)
-w, --workspace
Remove from all workspace members
--dry-run
Print changes without modifying files
--manifest-path <PATH>
Path to Cargo.toml
-h, --help
Print help information
--version
Print version information
DESCRIPTION
The cargo remove command removes specified dependencies from a project's Cargo.toml manifest file. It simplifies dependency management by automatically detecting and deleting entries from relevant sections such as [dependencies], [dev-dependencies], and [build-dependencies].
Dependencies can be specified by name (e.g., tokio) or with version constraints (e.g., tokio@1.0) to target specific requirements. For path, git, or other non-registry dependencies, use their identifiers directly.
In workspaces, use --workspace to remove from all member packages or --package to target specific ones. The --dry-run option previews changes without modifying files.
This command does not uninstall packages from the system or affect the lockfile directly; run cargo build afterward if needed to update. It's a counterpart to cargo add, streamlining workflows without manual Cargo.toml editing.
CAVEATS
Only removes direct dependencies listed in Cargo.toml; transitive deps unaffected. Requires Cargo 1.70+. Does not update Cargo.lock automatically.
EXAMPLES
cargo remove tokio
cargo remove --dry-run serde tokio@1.25
cargo remove -p my-crate log
HISTORY
Introduced in Cargo 1.70.0 (July 2023) as a native alternative to manual Cargo.toml edits or third-party tools like cargo-edit.
SEE ALSO
cargo-add(1), cargo-tree(1), cargo-metadata(1)


