SiftMac
Is it safe to delete? · Package caches · Updated 21 November 2026

Is it safe to delete ~/.cargo/registry and ~/.cargo/git?

By Mohit Nippanikar, who makes SiftMac

The short answer
On this page
  1. What’s in ~/.cargo
  2. Where it is
  3. How big it gets
  4. How to clear it
  5. What happens afterwards
  6. Questions

1. What’s in ~/.cargo

~/.cargo is Cargo’s home. The Cargo Book lists what’s in it, and only part of it is cache:

Folder or fileWhat it holdsSafe to clear?
registry/indexMetadata of the crates in the registryYes; fetched again
registry/cacheDownloaded crates, as .crate archivesYes; downloaded again
registry/srcThose archives unpacked, where rustc reads themYes; extracted again from registry/cache
git/dbBare clones of git dependenciesYes; cloned again
git/checkoutsThe commit each project needs, checked out from git/dbYes; checked out again
binPrograms from cargo install, and cargo, rustc and rustup if you use rustupNo
config.toml, credentials.tomlYour Cargo settings and registry loginNo

The Cargo Book is relaxed about the cache: you can remove any part of it, and Cargo will do its best to restore sources by re-extracting an archive, checking out the bare repository, or downloading again.

2. Where it is

~/.cargo/registry
~/.cargo/git

Cargo’s home defaults to $HOME/.cargo, and CARGO_HOME moves it. Rust compilers themselves are managed by rustup in a folder of its own; list them with rustup toolchain list and remove old ones with rustup toolchain uninstall.

3. How big it gets

du -sh ~/.cargo/registry/* ~/.cargo/git/* 2>/dev/null

Unpacked sources in registry/src take more room than the compressed archives in registry/cache they came from, and both hold every version any of your projects has used.

4. How to clear it

Close editors running rust-analyzer and let builds finish, then remove the parts you want. In order, from cheapest to most costly to rebuild:

rm -rf ~/.cargo/registry/src/*
rm -rf ~/.cargo/git/checkouts/*
rm -rf ~/.cargo/registry/cache/*
rm -rf ~/.cargo/git/db/*

The first two only cost re-extracting and checking out again, with no download. The last two mean downloading crates and cloning git dependencies again. The Cargo Book also mentions a third-party tool, cargo-cache, that shows the size of each part and clears them selectively.

Never run rm -rf ~/.cargo to save space. If you installed Rust with rustup, that removes cargo, rustc and rustup along with every program you installed.

5. What happens afterwards

Questions

Can I delete the whole ~/.cargo folder?

Not if you use rustup: ~/.cargo/bin holds the cargo, rustc and rustup commands, plus programs from cargo install. Clear registry and git instead.

Does Cargo clean its cache automatically?

Since Rust 1.88, yes, unless you’re offline. If you also run a Cargo older than 1.78, which doesn’t record when cache files were used, the release notes suggest setting cache.auto-clean-frequency = "never".

How do I remove programs I installed with cargo install?

cargo install --list shows them and cargo uninstall <name> removes one. Avoid deleting files in ~/.cargo/bin by hand: Cargo keeps a record of installed programs that it expects to match.

How SiftMac handles it. SiftMac doesn’t clear ~/.cargo. Its space map labels the folder as Rust’s package registry and installed tools and advises leaving it, since the registry part downloads again but the tools are yours. For old Rust projects, Developer files lists target folders next to a Cargo.toml.

Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works