Clearing the Cargo Cache on Mac: Is ~/.cargo/registry Safe to Delete?
~/.cargo/registry~/.cargo/gitYes, the Cargo cache is safe to delete. Both ~/.cargo/registry and ~/.cargo/git hold downloaded copies of Rust dependencies, and Cargo re-downloads whatever your projects actually use on the next build. You lose nothing permanent, just the bandwidth and a few minutes of that first rebuild. The one thing to get right: delete those two folders only, not the whole ~/.cargo directory.
What it is
Every time you build a Rust project, Cargo downloads the source code for each dependency from crates.io and stores it in ~/.cargo/registry. It keeps both the compressed .crate archives and the unpacked source trees so that future builds skip the download step. This cache is shared across every Rust project on your Mac, which is efficient, but it also means a copy of each version of every crate your projects pull in lands there, and dependency updates add new versions alongside the old ones.
~/.cargo/git is the same idea for dependencies pulled straight from git repositories instead of crates.io: Cargo keeps full clones and checkouts there. Cargo only recently learned to tidy up after itself: since Rust 1.88 in mid-2025 it quietly deletes cache files untouched for about three months, and older toolchains never delete anything. Crates you build regularly stay put either way, so on a Mac that sees regular Rust work the two folders together often reach several gigabytes.
Is it safe to delete?
Both folders are pure download cache, so deleting them breaks nothing. Your projects, their Cargo.toml files, and your installed Rust toolchain are untouched. The next time you run cargo build, Cargo re-downloads registry crates and re-clones git dependencies for whatever that project needs. On a decent connection that costs minutes, not hours, and it only fetches versions your projects still use, which is why the cache usually comes back smaller than it was.
The caution is about aim, not safety. Do not delete ~/.cargo itself: its bin subfolder holds every tool you installed with cargo install, plus the cargo and rustc shims if you use rustup, and its config file holds your settings. Stick to registry and git and you are fine. Diskmack identifies these two folders automatically and cleans them the safe way.
How to check its size
In Finder: In Finder, choose Go > Go to Folder (Shift-Command-G), type ~/.cargo and press Return. Select the registry and git folders, then press Command-I. The Info windows show the size of each.
In Terminal:
du -sh ~/.cargo/registry ~/.cargo/gitHow to clean it
- Quit any terminal or editor that is currently running a Rust build, including editors with rust-analyzer active, so nothing repopulates the cache mid-delete.
- In Finder, choose Go > Go to Folder and enter ~/.cargo.
- Select only the registry and git folders. Leave bin, config.toml, and everything else alone.
- Move the two folders to the Trash, then empty the Trash to actually reclaim the space.
- Next time you run cargo build in a project, Cargo re-downloads exactly the crates that project uses.
Cargo has no stable command for clearing these folders on demand; the automatic cleanup added in Rust 1.88 runs on Cargo's schedule, not yours. cargo clean is a different thing: it removes one project's target directory, not the shared download cache. A third-party subcommand exists (cargo install cargo-cache) if you want selective pruning, but deleting the folders by hand works just as well.
Will it come back?
Yes, and quickly. The cache starts refilling the moment you build any Rust project, and it grows again with every new dependency version you compile. Cargo's automatic cleanup only touches files unused for a few months, so on an active Rust setup the folders creep back toward their old size over weeks or months. Treat clearing it as periodic maintenance rather than a one-time fix. If you write Rust daily, once or twice a year is a realistic rhythm.
Common questions
Will deleting the Cargo cache break my Rust projects?
No. Your project source code and lock files are untouched. The next cargo build re-downloads every dependency it needs from crates.io or the original git repository. You need a network connection for that first rebuild, and it will take a few extra minutes. That is the entire cost.
Can I just delete the whole ~/.cargo folder?
Don't. ~/.cargo/bin contains every binary you installed with cargo install, and if you use rustup it also holds the shims that make the cargo and rustc commands work at all. Deleting the whole folder means reinstalling tools and possibly repairing your Rust setup. Delete only registry and git.
Is this the same as running cargo clean?
No. cargo clean deletes one project's target folder, which is that project's build output. The registry and git folders are the shared download cache used by all projects. They are separate, and on most Macs the per-project target folders are actually the bigger disk hogs.
How big does the Cargo cache get?
It scales with how many projects and dependencies you build. A casual setup might hold a few hundred megabytes; heavy Rust work can push the two folders to several gigabytes. Run du -sh ~/.cargo/registry ~/.cargo/git before deciding whether it is worth clearing.
Related folders
- Rust target Folder Is Huge: Is It Safe to Delete?
- Rustup toolchains taking up space on your Mac? What's safe to delete
- Is It Safe to Delete the Go Module Cache (~/go/pkg/mod) on a Mac?
- Can I Delete the .gradle Folder on My Mac? Yes, Here's How
- Can I Delete the .m2 Folder on My Mac? (Maven Repository Cache)