{{~*set command=“clean”}} {{~*set actionverb=“Clean”}} {{~*set multitarget=true}}
cargo-clean --- Remove generated artifacts
cargo clean [options]
Remove artifacts from the target directory that Cargo has generated in the past.
With no options, cargo clean will delete the entire target directory.
When no packages are selected, all packages and all dependencies in the workspace are cleaned.
{{#option “-p spec...” “--package spec...” }} Clean only the specified packages. This flag may be specified multiple times. See {{man “cargo-pkgid” 1}} for the SPEC format. {{/option}}
{{#option “--workspace” }} Clean artifacts of the workspace members. {{/option}}
{{/options}}
{{#option “--dry-run” }} Displays a summary of what would be deleted without deleting anything. Use with --verbose to display the actual files that would be deleted. {{/option}}
{{#option “--doc” }} This option will cause cargo clean to remove only the doc directory in the target directory. {{/option}}
{{#option “--release” }} Remove all artifacts in the release directory. {{/option}}
{{#option “--profile name” }} Remove all artifacts in the directory with the given profile name. {{/option}}
{{> options-target-dir }}
{{> options-target-triple }}
{{/options}}
{} {{> options-display }} {{/options}}
{} {{> options-manifest-path }}
{{> options-locked }}
{{> options-lockfile-path }} {{/options}}
{{> section-options-common }}
{{> section-environment }}
{{> section-exit-status }}
Remove the entire target directory:
cargo clean
Remove only the release artifacts:
cargo clean --release
{{man “cargo” 1}}, {{man “cargo-build” 1}}