Language toolchains & SDKs

Where Is the Cargo Cache on Mac, and Is It Safe to Clear in 2026?

If you work with Rust on macOS, you have probably noticed that disk usage climbs faster than you expect. Understanding the cargo cache location on Mac is the first step to reclaiming that space safely. The Cargo package manager stores downloaded crates, compiled artifacts, and registry indexes in a hidden home-directory folder, and on an active machine it can grow to several gigabytes without any warning. This guide explains exactly where the cache lives on macOS Sequoia and Tahoe (Apple Silicon and Intel), which parts are safe to delete, and how to clean them up without breaking your projects.

Where Is the Cargo Cache Stored on macOS?

Cargo follows the XDG convention by default but overrides it with the CARGO_HOME environment variable if you have set one. On a standard Mac installation the root of all Cargo data lives at:

  • ~/.cargo/ — the default CARGO_HOME

Inside that directory, the cache-relevant subdirectories are:

  • ~/.cargo/registry/ — downloaded crate source archives and the crates.io index
  • ~/.cargo/git/ — Git-based crate checkouts (crates sourced directly from GitHub or other repos)
  • ~/.cargo/bin/ — installed binaries (cargo install output); do not clear this

Compiled build artifacts, on the other hand, live inside each project's own target/ directory — typically at ~/path/to/your-project/target/ — and are completely separate from ~/.cargo. That distinction matters a great deal when deciding what to remove.

Folder-by-Folder Size Breakdown

The table below shows the typical contents and approximate sizes you might see on a Mac that has been doing active Rust development for six months to a year:

Path What it contains Typical size Safe to delete?
~/.cargo/registry/cache/ Compressed .crate archives downloaded from crates.io 500 MB – 3 GB Yes — Cargo re-downloads on next build
~/.cargo/registry/src/ Unpacked source trees used during compilation 1 GB – 5 GB Yes — rebuilt from the cache archives above
~/.cargo/registry/index/ Git-cloned crates.io index (package metadata) 200 MB – 600 MB Yes — re-fetched automatically
~/.cargo/git/db/ Bare Git repositories for git-sourced crates Varies widely Yes — re-cloned on next build
~/.cargo/git/checkouts/ Working-tree checkouts of git crates Varies widely Yes — re-checked-out on next build
~/.cargo/bin/ Binaries installed via cargo install 50 MB – 500 MB No — you lose the installed tools
project/target/ Per-project incremental build artifacts 1 GB – 10 GB per project Yes — cleaned by cargo clean

Is It Safe to Clear the Cargo Cache on Mac?

The short answer is yes — with one important exception. The registry/ and git/ subdirectories are pure download caches. Deleting them does not remove any of your code, and Cargo will transparently re-fetch whatever it needs the next time you run cargo build or cargo test. Your first build after clearing will take longer (and require an internet connection), but nothing will break permanently.

The folder you must never delete blindly is ~/.cargo/bin/. Every binary you installed with cargo install — tools like cargo-watch, cargo-expand, ripgrep, fd, or bat — lives there. Removing it means you have to reinstall each tool from source, which can take considerable time.

Similarly, leave ~/.cargo/env and ~/.cargo/config.toml untouched; those are configuration files, not cache.

How to Clear the Cargo Cache on Mac (Step by Step)

There are two main approaches: using the official cargo cache subcommand (recommended) or deleting directories manually.

Option 1 — Use cargo-cache (Recommended)

  1. Install the subcommand once: cargo install cargo-cache
  2. Preview what would be freed: cargo cache — this prints a size report without deleting anything.
  3. Remove only the registry source trees (safest first pass): cargo cache --autoclean
  4. For a more aggressive clean that also removes old registry cache entries: cargo cache --remove-dir all

The --autoclean flag is smart enough to keep the compressed .crate archives (so future builds are faster) while discarding the unpacked source trees that consume the most space.

Option 2 — Manual Deletion

  1. Check the current size: du -sh ~/.cargo/registry ~/.cargo/git
  2. Remove only registry sources and archives:
    rm -rf ~/.cargo/registry/src ~/.cargo/registry/cache
  3. Remove the crates.io index (will be re-cloned):
    rm -rf ~/.cargo/registry/index
  4. Remove git-sourced crates:
    rm -rf ~/.cargo/git

Leave ~/.cargo/bin/ alone unless you intend to reinstall every tool by hand.

Cleaning Per-Project Build Artifacts

The target/ directory inside each Rust project is often the single biggest consumer of disk space. Clean it with Cargo's built-in command from inside your project folder:

  • cargo clean — removes the entire target/ directory for that project

If you have dozens of projects spread across your Mac, finding and removing all of those target/ directories manually is tedious. You can locate them with:

  • find ~ -name target -path "*/Cargo.toml" -prune -o -name target -type d -print 2>/dev/null

A tool like Crumb can audit all of these build-artifact folders at once and show what is safe to delete before anything is actually removed, which is helpful when you have multiple projects and are not sure which target/ directories belong to active projects versus abandoned experiments.

How Much Space Can You Realistically Reclaim?

Results vary considerably based on how long you have been using Rust and how many crates you pull in. In practice, a developer who has been active for a year with several medium-sized projects typically sees:

  • Registry sources and cache: 2–6 GB freed
  • Per-project target/ directories: 5–20 GB freed across all projects
  • Git-sourced crates: a few hundred MB to 1 GB freed

Total savings of 10–25 GB are not unusual. If you also work with other language toolchains — Node.js node_modules, Java's Maven at ~/.m2/repository/, or Xcode's DerivedData at ~/Library/Developer/Xcode/DerivedData/ — the combined total can be substantially higher. For a full picture of what language toolchains are eating on your drive, see what is taking up space on your Mac.

Apple Silicon vs. Intel: Does the Cache Location Differ?

No. The Cargo cache location is the same on both Apple Silicon (M1/M2/M3/M4) and Intel Macs — ~/.cargo/ in your home directory. The only architecture-related difference you might notice is that on Apple Silicon you can have separate builds for aarch64-apple-darwin and x86_64-apple-darwin targets inside your target/ directory (for cross-compilation or Rosetta testing), which can roughly double per-project build artifact sizes.

Keeping the Cache Under Control Long-Term

Rather than doing a single large cleanup and then letting things grow back, consider these habits:

  • Run cargo cache --autoclean once a month to prune stale source trees automatically.
  • Run cargo clean in projects you are done with before archiving or deleting them.
  • Set a reminder to audit ~/.cargo/registry/ size with du -sh ~/.cargo/registry every few months.
  • If disk space is perpetually tight, consider setting CARGO_HOME to a location on an external drive for large personal projects while keeping the default path for work projects.

Understanding the interplay between the shared Cargo cache and per-project target/ directories is the key insight. The cache is a convenience layer; the target/ directories are where the real storage cost usually lives. For a broader look at how developer caches fit into overall Mac storage, the guide on what cache files are on a Mac is a useful companion read.

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

Where exactly is the Cargo cache stored on a Mac?
The Cargo cache lives in ~/.cargo/ inside your home directory by default. The two main cache subdirectories are ~/.cargo/registry/ (downloaded crate archives and the crates.io index) and ~/.cargo/git/ (checkouts of crates sourced from Git repositories). You can override this location by setting the CARGO_HOME environment variable.
Is it safe to delete the ~/.cargo/registry folder on Mac?
Yes, it is safe. The registry folder is a pure download cache — Cargo will re-fetch everything it needs the next time you build. Your source code and project files are completely unaffected. Your first build after deleting it will be slower and requires an internet connection.
Will clearing the Cargo cache delete my installed tools like ripgrep or cargo-watch?
No, as long as you leave ~/.cargo/bin/ alone. Installed binaries live in that bin folder, not in the registry or git cache directories. Only clear ~/.cargo/registry/ and ~/.cargo/git/ to reclaim space without losing your tools.
How do I clean up Rust build artifacts in my project's target/ folder?
Run cargo clean from inside your project directory. This removes the entire target/ directory for that project, which is often where the largest amount of space is consumed. Each project has its own target/ folder separate from the shared ~/.cargo cache.
How much disk space can I recover by clearing the Cargo cache on Mac?
It depends on your usage, but developers active for a year or more commonly free 2–6 GB from the registry cache alone. Per-project target/ directories can add another 5–20 GB across multiple projects, making total recoverable space of 10–25 GB quite realistic.