cargo-clean
Remove build artifacts from a Rust project
TLDR
Remove entire target directory
$ cargo clean
Remove release artifacts only$ cargo clean --release
Remove documentation only$ cargo clean --doc
Clean specific package$ cargo clean -p [package]
Preview without deleting$ cargo clean --dry-run
Clean specific profile$ cargo clean --profile [dev]
Clean for specific target architecture$ cargo clean --target [x86_64-unknown-linux-gnu]
Preview with verbose file listing$ cargo clean --dry-run -v
SYNOPSIS
cargo clean [options]
DESCRIPTION
cargo clean removes build artifacts generated by Cargo from the target directory. With no options, deletes the entire target directory. When packages are selected with -p, only those package artifacts are removed.
PARAMETERS
--release
Remove artifacts in the release directory.--profile name
Remove artifacts for the specified build profile.--doc
Remove only the doc directory in the target directory.-p, --package spec
Clean only the specified packages. May be specified multiple times.--target triple
Clean for the specified target architecture. May be specified multiple times.--target-dir dir
Custom target directory path.--dry-run
Show what would be deleted without actually deleting.-v, --verbose
Use verbose output. May be specified twice for very verbose output.-q, --quiet
Do not print cargo log messages.--color WHEN
Control when colored output is used (auto, always, never).--manifest-path path
Path to Cargo.toml.
CAVEATS
Without package selection, cleans all packages and dependencies in the workspace. The target directory can grow very large; regular cleaning frees significant disk space but requires a full rebuild afterward.
SEE ALSO
cargo(1), cargo-build(1), cargo-test(1)
