# Is it safe to delete Bun’s install cache?

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

## The short answer

- **Yes, the cache part.** `~/.bun/install/cache` holds packages Bun downloaded, and `bun pm cache rm` empties it. The rest of `~/.bun` can be Bun itself and your global tools, so keep it.
- **What it costs you:** the next `bun install` in each project downloads again. Projects set up with Bun’s global store also need that install before they run.
- **Does it come back?** Yes, with every `bun install`.
- SiftMac’s verdict: Rebuilds

## 1. What’s in ~/.bun

Depending on how you installed Bun, `~/.bun` can hold the tool itself as well as its cache:

- `~/.bun/bin`: the global bin folder, with commands from packages you added globally and, if you used Bun’s install script, the `bun` program too.
- `~/.bun/install/global`: packages installed with `bun add -g`.
- `~/.bun/install/cache`: every package Bun has downloaded from the registry, shared by all your projects. This is the part that grows.

On a Mac, Bun copies packages into each project’s `node_modules` with `clonefile`, the copy-on-write clone APFS offers. Bun’s docs point out what that means: the clone takes no extra disk space, and patching a package in one project can’t change it in another.

## 2. Where the cache is

```
~/.bun/install/cache
```

That’s the default. The `BUN_INSTALL_CACHE_DIR` variable or `dir` under `[install.cache]` in `bunfig.toml` can move it. Inside any project folder, `bun pm cache` prints the folder Bun is using.

If you turned on Bun’s global store, which is off by default, the package files your projects link to live in the cache as well, in its `links` folder.

## 3. How big it gets

The cache keeps each version of each package any of your projects installed, so it reflects how many projects you’ve worked on over time rather than how many you still have. Measure it next to the parts you keep:

```
du -sh ~/.bun/install/cache ~/.bun/install/global ~/.bun/bin
```

Because of the clones, the cache and your projects’ `node_modules` overlap on disk: together they use less space than their two sizes added up.

## 4. How to clear it

1. Stop `bun install`, `bun dev` and anything else Bun is running.
2. In a project folder, see what would be deleted, then clear it.

```
bun pm cache rm --dry-run
bun pm cache rm
```

This deletes everything in the cache folder, the global store in `links/` included, and keeps the folder itself. Bun can’t remove a single package this way: `bun pm cache rm <package>` is an error. For one package with stale registry data, Bun’s docs suggest `bun add <pkg> --force` or `bun update <pkg>` instead of clearing.

One quirk: `bun pm cache rm` takes the folder from `BUN_INSTALL_CACHE_DIR`, `--cache-dir` or `BUN_INSTALL`, and ignores a cache folder named in `bunfig.toml`. If you moved the cache there, pass the same folder with `--cache-dir`.

Don’t delete `~/.bun` as a whole unless you mean to remove Bun: with the install script, that takes the `bun` command and your global tools with it.

## 5. After clearing

- Most projects keep running, because their `node_modules` hold their own clones of every file.
- Projects that use the global store (`globalStore = true`) break until you run `bun install` in each, since their `node_modules` link into the folder you cleared.
- The next `bun install` downloads packages again, and `bun.lock` keeps every version the same.
- Packages you installed with `bun add -g` are in a different folder and stay.

## Questions

### Can I delete the whole ~/.bun folder?

Only when you’re removing Bun. With the install script, `~/.bun/bin` is where the `bun` command lives, so deleting the folder uninstalls Bun and every global package with it.

### Will bun pm cache rm break my projects?

Not with Bun’s defaults. On a Mac, Bun clones files into `node_modules`, so projects keep their own copies. Projects that opted into the global store link into the cache instead and need `bun install` again.

### Can I remove one package from Bun’s cache?

No; the cache is cleared as a whole. For one package with outdated registry data, `bun add <pkg> --force` or `bun update <pkg>` refreshes it without clearing anything.

### Why didn’t bun pm cache rm empty the folder I set in bunfig.toml?

Clearing ignores `bunfig.toml`, `.npmrc` and `.env` and uses `BUN_INSTALL_CACHE_DIR`, `--cache-dir` or `BUN_INSTALL`. Point one of those at your folder and run it again.

## How SiftMac handles it

SiftMac doesn’t clear `~/.bun`. Its space map labels the folder as the Bun runtime with its package cache, which downloads again when needed; `bun pm cache rm` does the clearing. For old Bun projects, Developer files lists `node_modules` with the space deleting would free, counting cloned files only for blocks they don’t share. A `bun` folder in `~/Library/Caches`, if your Mac has one, is cleared with App caches and left alone while `bun` is running.

Download: https://siftmac.com/SiftMac.dmg (scanning is free, and so is the first 2 GB of cleaning).

## Sources

- [Bun: the global install cache](https://bun.sh/docs/install/cache)
- [Bun: bun pm (cache, cache rm)](https://bun.sh/docs/pm/cli/pm)
- [Bun: the global store](https://bun.sh/docs/pm/global-store)

## Related

- [Is it safe to delete node_modules?](https://siftmac.com/safe-to-delete/node-modules)
- [Is it safe to delete ~/.npm, npm’s cache?](https://siftmac.com/safe-to-delete/npm-cache)
- [Is it safe to delete pnpm’s store?](https://siftmac.com/safe-to-delete/pnpm-store)
- [Honest sizes: only the space you really get back](https://siftmac.com/features/honest-sizes)
- [Xcode DerivedData, node_modules and Docker: what’s safe to delete on a developer’s Mac](https://siftmac.com/guides/developer-files-on-mac)

Canonical: https://siftmac.com/safe-to-delete/bun-cache
