Rust Guide

Cleaning Rust Cargo Registry, Git Checkouts, and Rustup Toolchains

Last updated: 2026-04-13

Rust developers accumulate crate downloads in ~/.cargo/registry, git checkouts in ~/.cargo/git, and multiple toolchain versions under ~/.rustup/toolchains. After months of development across multiple projects, these directories can consume 3–10 GB or more. Each project also generates a target/ directory with compiled artifacts that can be several gigabytes per project. All of these are regenerable — Cargo will re-download crates and recompile as needed.

What is the Cargo registry?

The Cargo registry at ~/.cargo/registry stores downloaded crate source files and metadata. Every dependency your projects use gets cached here, including all historical versions that were ever resolved. The registry index at ~/.cargo/registry/src contains extracted source code for every crate version. Over time this grows significantly, especially if you work on projects with many dependencies.

Cargo git checkouts

When your Cargo.toml depends on git repositories directly (rather than published crates), Cargo clones them into ~/.cargo/git. Each revision gets its own checkout. If you depend on several git-based crates or have switched between branches/revisions, this directory can grow to several hundred megabytes or more.

Rustup toolchains

Rustup manages multiple Rust toolchain versions under ~/.rustup/toolchains. Each toolchain (stable, beta, nightly, or specific versions) is a full copy of the Rust compiler, standard library, and tools — typically 500 MB–1 GB each. If you have accumulated several old toolchains, this adds up. You can list installed toolchains with `rustup toolchain list` and remove old ones with `rustup toolchain uninstall`.

Per-project target/ directories

Each Rust project generates a target/ directory containing compiled artifacts, incremental compilation data, and build script outputs. A single project's target/ can be 1–5 GB or more. CodeCleaner's Project Build Artifact Scanner finds every target/ directory across your filesystem and ranks them by size.

How CodeCleaner cleans Rust caches

CodeCleaner detects your Rust installation, calculates the size of the Cargo registry, git checkouts, and Rustup toolchains, and lets you clean the registry and git caches without removing your active toolchains. The Project Scanner separately finds and sizes every target/ directory across your projects for bulk cleanup.

Registry vs. target directories

Removing ~/.cargo/registry frees downloaded crates but the next build will re-fetch them. Removing target/ inside a project only affects that workspace and is the fastest way to drop gigabytes when you no longer need incremental artifacts. Keep at least one stable toolchain installed if you still compile production binaries.

Manual steps (Terminal)

You can do this manually with these commands, or use CodeCleaner to automate the process with a visual interface and safety checks. Each block shows a short label and the matching command.

Remove Cargo registry

rm -rf ~/.cargo/registry

Remove Cargo git checkouts

rm -rf ~/.cargo/git

List Rustup toolchains

rustup toolchain list

Uninstall an old toolchain

rustup toolchain uninstall <old-version>

Clean target directory (per project)

cargo clean  # run inside each project to delete target/

Or use CodeCleaner

CodeCleaner automates all of this with a native macOS app. It auto-detects your installed tools, scans the relevant paths in parallel, shows per-item sizes, and lets you clean safely with one click. Free scan, no account required.

Related topics

Short landing pages focused on specific searches; each links back to the same download and safety model as the homepage.

CodeCleaner on the home page

Download, feature overview, and comparison with generic cleaners live on the main landing page.

Open homepage — download