A cargo subcommand for cleaning up unused build files generated by Cargo
Rust
995
180 commits
updated May 26, 2026
⚠️⚠️ Warning: cargo-sweep is currently unmaintained. ⚠️⚠️
The project has issues and is lacking a dedicated maintainer to contribute and/or review contributions from others.
If you're looking for an alternative, check cargo-clean-all.
If you want to discuss the possibility of a handover, reach out to one of these two previous maintainers:
Or open an issue.
cargo-sweep is a Cargo subcommand for deleting old or unused build artifacts from target/ without doing a full cargo clean.
It is useful when you want to:
target/ directoriescargo clean removes everything, cargo-sweep lets you clean more selectively.
For example, you can remove artifacts:
target/ directory drops below a size limitcargo install cargo-sweep
After installation, use it as a Cargo subcommand:
cargo sweep --help
Clean artifacts older than 30 days in the current project:
cargo sweep --time 30
Preview what would be deleted:
cargo sweep --dry-run --time 30
Clean artifacts not built by currently installed Rust toolchains:
cargo sweep --installed
Keep only artifacts for specific toolchains:
cargo sweep --toolchains stable,nightly
Shrink target/ until it is below 10 GiB:
cargo sweep --maxsize 10GiB
Clean everything in a specific project:
cargo sweep --all path/to/project
Recursively sweep all Cargo projects under a directory:
cargo sweep --recursive --time 30 path/to/workspace-root
If you want to keep only artifacts used after a certain point in time:
cargo sweep --stamp
# run builds, tests, benches, etc.
cargo sweep --file
This writes a timestamp marker, then later removes artifacts older than that marker.
In a rustup environment, cargo-sweep can identify artifacts from installed toolchains.
If rustup is unavailable, it falls back to invoking rustc directly.
For full usage:
cargo sweep --help
Standalone binary help:
cargo-sweep --help
cargo clean (built-in).cargo-clean-all.Overall
Maintained
Code review
crates.io
Latest release
Releases this year
(top 24 of 63)
3,108 followers · starred Jun 2025
1,854 followers · starred May 2023
402 followers · starred Nov 2018
14,016 followers · starred Oct 2019
A cargo subcommand for cleaning up unused build files generated by Cargo
Rust
995
180 commits
updated May 26, 2026
⚠️⚠️ Warning: cargo-sweep is currently unmaintained. ⚠️⚠️
The project has issues and is lacking a dedicated maintainer to contribute and/or review contributions from others.
If you're looking for an alternative, check cargo-clean-all.
If you want to discuss the possibility of a handover, reach out to one of these two previous maintainers:
Or open an issue.
cargo-sweep is a Cargo subcommand for deleting old or unused build artifacts from target/ without doing a full cargo clean.
It is useful when you want to:
target/ directoriescargo clean removes everything, cargo-sweep lets you clean more selectively.
For example, you can remove artifacts:
target/ directory drops below a size limitcargo install cargo-sweep
After installation, use it as a Cargo subcommand:
cargo sweep --help
Clean artifacts older than 30 days in the current project:
cargo sweep --time 30
Preview what would be deleted:
cargo sweep --dry-run --time 30
Clean artifacts not built by currently installed Rust toolchains:
cargo sweep --installed
Keep only artifacts for specific toolchains:
cargo sweep --toolchains stable,nightly
Shrink target/ until it is below 10 GiB:
cargo sweep --maxsize 10GiB
Clean everything in a specific project:
cargo sweep --all path/to/project
Recursively sweep all Cargo projects under a directory:
cargo sweep --recursive --time 30 path/to/workspace-root
If you want to keep only artifacts used after a certain point in time:
cargo sweep --stamp
# run builds, tests, benches, etc.
cargo sweep --file
This writes a timestamp marker, then later removes artifacts older than that marker.
In a rustup environment, cargo-sweep can identify artifacts from installed toolchains.
If rustup is unavailable, it falls back to invoking rustc directly.
For full usage:
cargo sweep --help
Standalone binary help:
cargo-sweep --help
cargo clean (built-in).cargo-clean-all.Overall
Maintained
Code review
crates.io
Latest release
Releases this year
(top 24 of 63)
3,108 followers · starred Jun 2025
1,854 followers · starred May 2023
402 followers · starred Nov 2018
14,016 followers · starred Oct 2019