~/.cargo/registry is where Cargo stores downloaded Rust crates, their unpacked sources and the registry index. It is safe to delete. The next cargo build downloads whatever crates it needs again, so you need a network connection. Your own projects and their target folders are not affected.
- Path
~/.cargo/registry- What it is
- Downloaded .crate archives, unpacked sources and the registry index
- Typical size
- Hundreds of megabytes to several gigabytes; Cargo does not cap it
- Made by
- Cargo (Rust)
- Safe to delete?
- Safe to clear
- Comes back?
- Yes, Cargo downloads crates again on the next build, which needs a network connection
What is in this folder?
The Cargo Book describes the layout: downloaded dependencies sit in registry/cache as .crate archives, and registry/src holds the extracted files that the compiler reads. Git dependencies are cloned separately into ~/.cargo/git.
Because crates are stored twice (archive and unpacked), the folder grows quickly on a Mac that has built many Rust projects.
Is it safe to delete?
Yes. Nothing in the registry folder is unique: crates come from crates.io. Projects with a Cargo.lock fetch the same versions. The exception is if a crate version has been yanked or removed since, in which case an offline copy in your cache may be your only one.
Do not delete the rest of ~/.cargo. It holds bin (installed tools such as cargo-installed programs) and credentials.toml, which holds your login token.
How do I clear it by hand?
- Stop any running
cargo buildor rust-analyzer session. - Delete the registry folder only.
- Build a project, and Cargo downloads crates again.
rm -rf ~/.cargo/registry
rm -rf ~/.cargo/gitThe second line is optional and removes cached Git dependencies. Runcargo cleaninside a project to remove itstargetfolder.
How do I stop it growing?
Delete the registry now and then. For project build output, cargo clean in finished projects frees often larger space than the registry.
How Clean House handles it
Clean House recognizes ~/.cargo/registry as a Rust crates cache and ~/.cargo/git as a Cargo Git cache, both made by Cargo and both marked as downloading again. It treats ~/.cargo/credentials as protected and never offers it.