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

Is it safe to delete? · Package caches · Updated 21 November 2026. By Mohit Nippanikar, who makes SiftMac.

## The short answer

- **Yes**, those two. They’re Cargo’s cache of crates and git dependencies, which Cargo extracts or downloads again. Don’t delete `~/.cargo` as a whole: with rustup, its `bin` folder holds `cargo` and `rustc` themselves.
- **What it costs you:** the next build re-extracts or downloads the crates it needs, and needs the network for anything no longer cached.
- **Does it come back?** Yes. Since Rust 1.88, Cargo also trims old cache files by itself.
- SiftMac’s verdict: Rebuilds

## 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 file | What it holds | Safe to clear? |
| --- | --- | --- |
| `registry/index` | Metadata of the crates in the registry | Yes; fetched again |
| `registry/cache` | Downloaded crates, as `.crate` archives | Yes; downloaded again |
| `registry/src` | Those archives unpacked, where rustc reads them | Yes; extracted again from `registry/cache` |
| `git/db` | Bare clones of git dependencies | Yes; cloned again |
| `git/checkouts` | The commit each project needs, checked out from `git/db` | Yes; checked out again |
| `bin` | Programs from `cargo install`, and `cargo`, `rustc` and `rustup` if you use rustup | **No** |
| `config.toml`, `credentials.toml` | Your Cargo settings and registry login | **No** |

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

- The next `cargo build` re-extracts or downloads the crates listed in `Cargo.lock`, at exactly those versions.
- Builds run with `--offline` or `--frozen` fail for anything no longer cached.
- Compiled output in your projects isn’t affected; for that space, see [Rust target folders](https://siftmac.com/safe-to-delete/rust-target-folder).
- Cargo keeps trimming by itself: since 1.88 it removes downloaded files not used for 3 months and files obtained from your own disk, such as extracted sources, not used for 1 month, except when running offline.

## 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: https://siftmac.com/SiftMac.dmg (scanning is free, and so is the first 2 GB of cleaning).

## Sources

- [The Cargo Book: Cargo Home](https://doc.rust-lang.org/cargo/guide/cargo-home.html)
- [Rust blog: Announcing Rust 1.88.0 (automatic cache cleaning)](https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/)
- [The rustup book: Installation](https://rust-lang.github.io/rustup/installation/index.html)

## Related

- [Is it safe to delete a Rust project’s target folder?](https://siftmac.com/safe-to-delete/rust-target-folder)
- [Is it safe to delete ~/go/pkg/mod and Go’s build cache?](https://siftmac.com/safe-to-delete/go-module-cache)
- [Xcode DerivedData, node_modules and Docker: what’s safe to delete on a developer’s Mac](https://siftmac.com/guides/developer-files-on-mac)
- [What fills a developer’s Mac, and what’s safe to delete](https://siftmac.com/for/developers)

Canonical: https://siftmac.com/safe-to-delete/cargo-registry
