← 返回命令列表

Linux command

cargo-clean 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

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

cargo clean --target [x86_64-unknown-linux-gnu]

Preview with verbose

cargo clean --dry-run -v

说明

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.

参数

--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.

FAQ

What is the cargo-clean command used for?

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.

How do I run a basic cargo-clean example?

Run `cargo clean` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --release do in cargo-clean?

Remove artifacts in the release directory.