The short answer
- 01
Safe to delete. ~/.cargo/registry holds crate archives and unpacked sources; ~/.cargo/git holds clones of git dependencies.
- 02
Cargo writes both on cargo build, cargo fetch and cargo install, shared by every Rust project on your Mac.
- 03
You lose download time: the next build downloads or checks out each dependency again.
- 04
The command: rm -rf ~/.cargo/registry ~/.cargo/git. Cargo has no stable command to empty them, but since 1.88 it trims old files itself.
- 05
Keep ~/.cargo/bin. It holds cargo, rustc shims and tools from cargo install.
See its real size on your Mac. Hoardless measures this folder and previews the delete.Download free trial
What are ~/.cargo/registry and ~/.cargo/git?
They are Cargo's dependency caches, inside Cargo home. The Cargo Book says Cargo home is $HOME/.cargo/ by default and moves with the CARGO_HOME environment variable.
registry/index: metadata of all available crates in a registry, such as crates.io.registry/cache: downloaded dependencies as gzip archives with a.crateextension.registry/src: those archives unpacked, where rustc finds the.rsfiles.git/db: bare clones of git repositories your crates depend on.git/checkouts: the commits those dependencies need, checked out from the bare clones. Several commits of one repo can sit side by side.
The Cargo Book warns that the internal layout of Cargo home is not stabilized and may change.
What writes it and why does it grow?
cargo build, cargo fetch and cargo install write to it. Every crate version any project needs is downloaded once and kept for all projects.
- Each version twice: a crate is kept as a
.cratearchive and again unpacked inregistry/src. - Every commit of git dependencies: each pinned commit gets its own checkout.
- Automatic trimming since 1.88: the Rust 1.88 release notes say Cargo removes network downloads not accessed in 3 months and local files not accessed in 1 month, except when running offline.
Each project's compiled output is not here. It lives in that project's target folder, and cargo clean removes it.
How big does the Cargo cache get?
It depends on how many crates and versions your projects use, so there is no normal size. Measure your own:
du -sh ~/.cargo/registry ~/.cargo/git
Prints both cache sizes. Removes nothing.
du -sh ~/.cargo/registry/* ~/.cargo/git/*
Splits them into index, cache, src, db and checkouts, so you can see which part is large.
Is it safe to delete ~/.cargo/registry?
The Cargo Book: you can always remove any part of the cache, and Cargo restores sources by re-extracting an archive, checking out a bare repo or downloading again.
| What | Verdict | What you lose |
|---|---|---|
~/.cargo/registry | Safe | Downloaded crates. The next build downloads them again. |
~/.cargo/git | Safe | Git dependency clones. The next build fetches them again. |
| Deleting before working offline | Careful | cargo build --offline fails until the cache refills. |
~/.cargo/bin, config.toml, credentials.toml | Never | Your Rust tools, Cargo settings and registry tokens. |
How do I delete the Cargo cache?
Cargo has no stable command that empties these folders, so deleting them is the documented route. Stop running builds first:
rm -rf ~/.cargo/registry ~/.cargo/git
Deletes both caches permanently, without the Trash. Use $CARGO_HOME instead of ~/.cargo if you set it.
rm -rf ~/.cargo/registry/src
A smaller step: removes only the unpacked sources. Cargo re-extracts them from the .crate archives without downloading.
The manual way: in Finder, press Shift+Cmd+G, go to ~/.cargo, and drag registry and git to the Trash. The Cargo Book also points to the third-party cargo-cache crate for clearing selected parts.
What Hoardless does: its Cargo and Go detector lists ~/.cargo/registry and ~/.cargo/git as two Auto tier items and moves them to the Trash after you review the plan, logged in the undo log.
What comes back and when?
Only the crates your next builds need. The first cargo build in each project downloads its dependencies and refills the index, cache and sources. Crates no current project uses stay gone.
Since Cargo 1.88 also trims files it has not used in months, a cache you clear rarely grows back to its old size.
See Cargo caches next to your other toolchains
Hoardless sizes ~/.cargo/registry and ~/.cargo/git (Auto tier, moved to the Trash) next to the Go module cache, Homebrew, Gradle and Maven, and previews the plan before anything moves.
14-day full trial. macOS 14 or later.
Questions
Does Cargo clean the registry by itself?
Since Rust 1.88, yes: Cargo removes files downloaded from the network that were not accessed in 3 months, and files from the local system not accessed in 1 month. It skips this when running offline.
Does cargo clean empty ~/.cargo/registry?
No. cargo clean removes a project's target folder. The registry and git caches in Cargo home are separate.
Is it safe to delete all of ~/.cargo?
No. ~/.cargo/bin holds cargo, the rustup shims and every tool you installed with cargo install, and ~/.cargo can hold your config.toml and credentials.
Where is Cargo home if I set CARGO_HOME?
Wherever CARGO_HOME points. The registry and git folders are inside it, so measure and delete them there.
New guides by email
New guides and Hoardless releases, twice a month at most.
Confirm first. Unsubscribe in one click. Privacy.