A cargo subcommand for cleaning up unused build files generated by Cargo
open sourceMITself-hostablefree
cargo-sweep deletes old or unused build artifacts from Rust target directories without a full cargo clean: by age, by toolchains no longer installed, or until a target directory is under a size limit, across many projects at once. The README currently marks it as unmaintained and points to cargo-clean-all.
Problems it solves
- my Rust target folder is 40GB and cargo clean throws away everything
- delete build artifacts older than 30 days but keep recent ones
- clean out artifacts from Rust toolchains I've uninstalled
- shrink the target directory before caching it in CI
- clean every Rust project under ~/code in one go
- keep target/ below a size limit automatically
- nightly toolchain updates leave gigabytes of stale build files behind
- preview which build files would be deleted before removing them
Features
- clean by age
- clean artifacts from uninstalled toolchains
- size limit
- recursive across projects
- dry run
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what cargo-sweep does.
- npkill Easily find and remove old and heavy node_modules, artifacts, caches and dev leftovers
- Kondo Cleans dependencies and build artifacts from your projects.
- Mr Boxington (mbx) A shared cache for Cargo builds
- cargo-cache manage cargo cache (${CARGO_HOME}, ~/.cargo/), print sizes of dirs and remove dirs selectively
- Kache Build once. Reuse the work.
- Mole Open-source Mac and PC cleaner. Keep your machine clean, light, and running like new.
