Skip to content

clovu/cargo-clean-global

Repository files navigation

cargo-clean-global

cargo-clean-global is a Cargo plugin that finds Cargo projects on your machine and cleans their build output directories in one command.

It is designed as the practical equivalent of a global Cargo clean operation. Because Cargo plugins cannot extend the built-in cargo clean command with a --global flag, this project is used as:

cargo clean-global

Direct execution via cargo-clean-global is intentionally rejected. Use the Cargo subcommand form only.

Installation

cargo install cargo-clean-global

Install from a local checkout during development:

cargo install --path .

Usage

Clean all discovered Cargo project build directories:

cargo clean-global

Skip the confirmation prompt and clean immediately:

cargo clean-global --yes

Preview what would be cleaned without deleting anything:

cargo clean-global --dry-run

Restrict scanning to a specific directory:

cargo clean-global --root ~/projects

Restrict scanning to multiple directories:

cargo clean-global --root ~/projects --root /work/rust

Configure default scan roots in your global Cargo config (used when --root is not provided):

$CARGO_HOME/config.toml (or $CARGO_HOME/config). In most setups, this is ~/.cargo/config.toml.

[cargo-clean-global]
roots = ["~/projects", "../rust-workspaces"]

You can also set a single string value:

[cargo-clean-global]
roots = "~/projects"

Root precedence:

  1. --root values passed on CLI
  2. [cargo-clean-global].roots from global Cargo config
  3. Built-in defaults (home/current directory strategy)

Path behavior for [cargo-clean-global].roots:

  • ~ is expanded to your home directory.
  • Relative paths are resolved relative to the Cargo config file directory.

By default, scanner skips hidden directories whose names start with .. If your Rust project is inside a hidden directory, explicitly pass that path with --root.

Example:

cargo clean-global --root ~/.config/my-rust-projects

Show help:

cargo clean-global --help

Contribution

Contributions of any kind are welcome! If you have ideas or suggestions, feel free to open an issue or submit a pull request.

Release Automation

Install the local release helpers:

cargo install cargo-release
cargo install git-cliff
brew install just

Prepare and verify a release without pushing anything:

just release-dry-run 1.2.5

Create the release commit and tag locally:

just release 1.2.5

Create the release commit, tag, and push them to origin:

just release-execute 1.2.5

Pushing a version tag that matches v<package-version> runs the release workflow, builds the release artifacts, creates the GitHub Release, and publishes the crate to crates.io. The release workflow publishes to crates.io only after the GitHub Release and its binary artifacts are created.

Repository maintainers must configure the CRATES_IO_TOKEN GitHub Actions secret before using this flow.

License

MIT License © 2026 Clover You

About

A safe Cargo plugin that cleans target directories across local Cargo projects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors