Cargo Registry Cache on Mac: Safe to Delete?

Medium riskPackage managers & build toolsUpdated

Facts from the app
Location
  • ~/.cargo/registry/cache
Risk level
Medium riskSafe to remove, but the tool that owns it re-downloads or rebuilds it on next use, which costs time and bandwidth. Listed, never pre-selected.
Selected by default
No — you choose whether to include it
What Freshist does
Moves the selected items to the Trash, so you can undo. Nothing is deleted outright.
In the app
Clean → Cargo Registry Cache — “Rust dependency download cache — cargo re-downloads crates on next build.”

From Freshist's own cleaning rules — the same catalog the app uses.

What lives in the registry cache

Cargo keeps its global state in CARGO_HOME, which is ~/.cargo unless you changed it. The Cargo book's "Cargo Home" chapter splits the downloaded material into three places:

FolderContentsHow it comes back
registry/cacheCompressed .crate archives from crates.io (or another registry)Re-downloaded
registry/srcThose archives unpacked into source files that rustc compilesRe-extracted from the archive, or downloaded again
git/db, git/checkoutsBare clones and checkouts of git dependenciesRe-cloned
registry/indexThe sparse registry indexRefetched on the next resolve

This page is about registry/cache, the archives. Each subfolder inside it is named after a registry host plus a hash, for example index.crates.io-1949cf8c6b5b557f.

Why it fills up

Every version of every crate you've ever built against stays in the cache. Rust projects tend to have deep dependency trees, and updating Cargo.lock across a few projects quickly leaves older versions of serde, tokio, syn and friends behind.

Before Rust 1.88, Cargo never removed anything here on its own. Since 1.88 (June 2025), it garbage-collects its home directory automatically. The Rust 1.88.0 announcement gives the defaults: files downloaded from the network go after three months without access, and files obtained locally (such as extracted sources) after one month. The cleanup is skipped when Cargo runs with --offline or --frozen. On an older toolchain, the cache only grows.

What happens if you delete it

The Cargo book is direct about it: you can remove any part of the cache, and Cargo will restore sources when a crate needs them by re-extracting an archive, checking out a bare repo, or downloading again.

In practice:

  • The next build of each project downloads the crates it can't find, then compiles as usual.
  • Your project's target/ folder is untouched, so compiled artifacts stay valid.
  • Binaries in ~/.cargo/bin keep working.
  • Builds that use --offline or --frozen fail for missing crates until you're online again.

Measure it before touching it

du -sh ~/.cargo/registry/cache ~/.cargo/registry/src ~/.cargo/git
ls ~/.cargo/registry/cache/*/ | head
echo "${CARGO_HOME:-$HOME/.cargo}"     # where Cargo home actually is

If CARGO_HOME points somewhere else, the paths above move with it.

Clear it with Cargo's tools

Cargo has no stable command that empties the global cache on demand. The automatic cleanup described above is stable, but the manual gc subcommand was still an unstable, nightly-only feature in the 1.88 announcement. Updating your toolchain with rustup update is the simplest way to get the automatic cleanup, and cargo clean only works on a project's target/ folder.

The Cargo book also points to the third-party cargo-cache tool, which shows the size of each part of Cargo home and can clear selected parts.

Deleting the folder by hand is equally fine. Quit any running cargo or rust-analyzer process, then remove ~/.cargo/registry/cache (and registry/src if you want the extracted sources gone too). Leave ~/.cargo/bin, config.toml and credentials.toml alone.

When it's worth keeping

Keep the cache when you're about to work offline, or on a CI runner where re-downloading costs more than the disk space. Otherwise it's routine to clear. Most of the disk Rust uses on a typical Mac sits in project target/ folders, not here, so check those too. The broader picture is in developer caches on Mac, and the Go build cache guide covers a similar folder for Go.

Sources

Frequently asked questions

Is it safe to delete the whole ~/.cargo folder?

No. ~/.cargo/bin holds rustup's proxies (cargo, rustc) and every tool you installed with cargo install, and config.toml and credentials.toml hold your settings and registry token. Only the registry and git subfolders are caches.

Does this affect the target folder in my projects?

No. Build output lives in each project's target directory, which is usually far larger than the registry cache. cargo clean inside a project removes that.

Will cargo build work offline after clearing?

Not reliably. A build with --offline fails as soon as it needs a crate Cargo can no longer find locally, so fetch dependencies (cargo fetch) before you go offline.

Keep reading