# Cargo Registry Cache on Mac: Safe to Delete?

> ~/.cargo/registry/cache stores the .crate archives Cargo downloads. Deleting it is safe; Cargo fetches crates again the next time a build needs them.

- Updated: 2026-10-10
- URL: https://fresh.ist/caches/cargo/

**TL;DR:** Yes, you can delete it. ~/.cargo/registry/cache holds compressed .crate files that Cargo downloaded from crates.io. Your code, Cargo.lock and installed binaries aren't stored there. The next build that needs a missing crate downloads it again. Since Rust 1.88 Cargo also removes long-unused downloads on its own, so clearing by hand mostly helps when you want the space back now.

## Facts from the Freshist app

- Category in Clean: Cargo Registry Cache — "Rust dependency download cache — cargo re-downloads crates on next build."
- Location: `~/.cargo/registry/cache`
- Risk level: Medium risk — Safe 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
- What Freshist does: Moves the selected items to the Trash, so you can undo. Nothing is deleted outright.

## 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](https://doc.rust-lang.org/cargo/guide/cargo-home.html) splits the downloaded material into three places:

| Folder | Contents | How it comes back |
|---|---|---|
| `registry/cache` | Compressed `.crate` archives from crates.io (or another registry) | Re-downloaded |
| `registry/src` | Those archives unpacked into source files that `rustc` compiles | Re-extracted from the archive, or downloaded again |
| `git/db`, `git/checkouts` | Bare clones and checkouts of git dependencies | Re-cloned |
| `registry/index` | The sparse registry index | Refetched 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](https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/) 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

```sh
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`](https://crates.io/crates/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](/blog/developer-caches-mac/), and the [Go build cache](/caches/go-build/) guide covers a similar folder for Go.

## Sources

- [The Cargo Book: Cargo Home](https://doc.rust-lang.org/cargo/guide/cargo-home.html)
- [The Cargo Book: cargo clean](https://doc.rust-lang.org/cargo/commands/cargo-clean.html)
- [Rust blog: Rust 1.88.0, automatic cache cleaning](https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/)

## 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.

---

Canonical page: https://fresh.ist/caches/cargo/
Official site: https://fresh.ist/ (fresh.ist only)
Generated: 2026-10-10
