Is it safe to delete Bun’s install cache?
- Yes, the cache part.
~/.bun/install/cacheholds packages Bun downloaded, andbun pm cache rmempties it. The rest of~/.buncan be Bun itself and your global tools, so keep it. - What it costs you: the next
bun installin 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, thebunprogram too.~/.bun/install/global: packages installed withbun 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
- Stop
bun install,bun devand anything else Bun is running. - 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_moduleshold their own clones of every file. - Projects that use the global store (
globalStore = true) break until you runbun installin each, since theirnode_moduleslink into the folder you cleared. - The next
bun installdownloads packages again, andbun.lockkeeps every version the same. - Packages you installed with
bun add -gare 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 SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works