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:
- @jyn514 ("jyn" in the Rust-Lang's Zulip)
- @marcospb19 (contact info here)
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:
- shrink large
target/directories - avoid bloated CI caches
- clean many Rust projects at once
cargo clean removes everything, cargo-sweep lets you clean more selectively.
For example, you can remove artifacts:
- older than a number of days
- not built by currently installed toolchains
- until a
target/directory drops below a size limit
cargo install cargo-sweepAfter installation, use it as a Cargo subcommand:
cargo sweep --helpClean artifacts older than 30 days in the current project:
cargo sweep --time 30Preview what would be deleted:
cargo sweep --dry-run --time 30Clean artifacts not built by currently installed Rust toolchains:
cargo sweep --installedKeep only artifacts for specific toolchains:
cargo sweep --toolchains stable,nightlyShrink target/ until it is below 10 GiB:
cargo sweep --maxsize 10GiBClean everything in a specific project:
cargo sweep --all path/to/projectRecursively sweep all Cargo projects under a directory:
cargo sweep --recursive --time 30 path/to/workspace-rootIf you want to keep only artifacts used after a certain point in time:
cargo sweep --stamp
# run builds, tests, benches, etc.
cargo sweep --fileThis 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 --helpStandalone binary help:
cargo-sweep --helpcargo clean(built-in).cargo-clean-all.