LinuxCommandLibrary

cargo-remove

Remove dependencies from a Cargo.toml manifest

TLDR

Remove dependency

$ cargo remove [serde]
copy
Remove dev dependency
$ cargo remove --dev [mockall]
copy
Remove build dependency
$ cargo remove --build [cc]
copy
Remove multiple dependencies
$ cargo remove [serde] [tokio] [regex]
copy
Remove target-specific dependency
$ cargo remove --target [x86_64-pc-windows-gnu] [winapi]
copy
Dry run
$ cargo remove --dry-run [package]
copy

SYNOPSIS

cargo remove [options] dep...

DESCRIPTION

cargo remove removes one or more dependencies from the Cargo.toml manifest file. It can target regular dependencies, dev-dependencies, build-dependencies, or platform-specific dependency sections.
The command modifies Cargo.toml directly but does not update Cargo.lock until the next build or `cargo update`. Multiple dependencies can be removed in a single invocation. Use `--dry-run` to preview changes before applying them.

PARAMETERS

--dev, -D

Remove from dev-dependencies
--build, -B
Remove from build-dependencies
--target triple
Remove from target-specific dependencies
-p, --package spec
Package to modify
--dry-run
Show changes without modifying manifest
--manifest-path path
Path to Cargo.toml
-v, --verbose
Verbose output
-q, --quiet
Suppress output

CAVEATS

Does not remove dependencies from Cargo.lock until next build. Use cargo-machete to detect unused dependencies.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community