Folder

Is the Bun install cache (~/.bun/install/cache) safe to delete on a Mac?

Yes, the Bun install cache is safe to delete: it holds only downloaded packages, bun pm cache rm clears it, and the next bun install downloads what it needs again.

1 safe1 careful1 never

updated read 3 minfor Bun 1.x on macOS

The short answer

  1. 01

    Safe to delete. ~/.bun/install/cache is Bun's global package cache. Your code and lockfile are not in it.

  2. 02

    BUN_INSTALL_CACHE_DIR moves it. If that variable or install.cache.dir in bunfig.toml is set, the cache is there instead.

  3. 03

    You lose download time: the next bun install fetches packages from the registry again.

  4. 04

    The command: bun pm cache rm. bun pm cache prints the path first.

See its real size on your Mac. Hoardless measures this folder and previews the delete.Download free trial

What is the ~/.bun/install/cache folder?

It is Bun's global package cache. Bun's docs say downloaded packages are stored in ~/.bun/install/cache unless the path is changed. Every project you install with Bun reads from the same cache.

Two settings change the location:

  • BUN_INSTALL_CACHE_DIR: an environment variable that sets a custom cache path.
  • [install.cache] in bunfig.toml: dir sets the folder, and disable = true skips the global cache so Bun extracts packages into node_modules/.cache instead.
bun pm cache

Prints the cache path Bun is using. Removes nothing.

What writes it and why does it grow?

bun install and bun add write to it. Each package version Bun downloads is kept so the next install of that version needs no network.

  • Old versions stay after you upgrade a dependency.
  • Shared by every Bun project on your Mac, including ones you deleted.
  • Linked by cloning on macOS: Bun's docs say it uses clonefile on macOS, a copy-on-write clone that takes no extra space until a file is written. Linux and Windows use hard links.

How big does the Bun cache get?

It depends on how many packages and versions you have installed, so there is no normal size. Measure your own:

du -sh ~/.bun/install/cache

Prints the default cache size. Removes nothing.

du -sh "${BUN_INSTALL_CACHE_DIR:-$HOME/.bun/install/cache}"

Measures the custom location when BUN_INSTALL_CACHE_DIR is set in your shell, and the default otherwise.

Because of clonefile, du counts blocks the cache shares with node_modules clones, so the figure is the most you could free, not a promise.

Is it safe to delete the Bun cache?

Yes: it is a download cache, and Bun refills it on the next install.

WhatVerdictWhat you lose
~/.bun/install/cacheSafeCached packages. The next install downloads them again.
Clearing right before working offlineCarefulInstalls fail without a network until the cache refills.
~/.bun/bin or all of ~/.bunNeverThe bun binary itself when installed with Bun's script. Bun stops working.

How do I clear the Bun cache?

Use Bun's own command:

bun pm cache rm --dry-run

Lists the folders that would be deleted. Removes nothing.

bun pm cache rm

Bun's docs say it deletes everything in the cache directory and keeps the directory itself. It refuses to clear a folder that is or contains your project, your home folder or your Bun install.

The manual way: stop any running bun install, then drag the folder bun pm cache printed to the Trash.

What Hoardless does: it has no Bun detector, so the Bun cache does not appear in Dev Caches. Explain names ~/.bun/install/cache as Bun's global package cache, and if you choose to reclaim it from there, Hoardless moves it to the Trash at the Confirm tier, logged in the undo log. It never runs bun pm cache rm.

What comes back and when?

Packages come back on the next install. Each bun install downloads what that project's lockfile needs and stores it in the cache again. Versions no project installs stay gone.

Clearing the cache leaves each project's node_modules in place. Those are a separate cleanup, covered in node_modules.

Find what else your projects left behind

Hoardless explains ~/.bun/install/cache and can move it to the Trash at the Confirm tier. Its Dev Caches list covers npm, Yarn 1 and pnpm with their own commands, and its Unused view finds node_modules in idle repos.

14-day full trial. macOS 14 or later.

Questions

What is BUN_INSTALL_CACHE_DIR?

An environment variable that sets where Bun keeps its global package cache, overriding the default ~/.bun/install/cache.

Can I remove one package from the Bun cache?

No. Bun's docs say bun pm cache rm with a package name is an error. The command clears the whole cache.

Will deleting ~/.bun uninstall Bun?

Yes, if you installed Bun with its install script, because the bun binary lives in ~/.bun/bin. Delete only ~/.bun/install/cache to keep Bun.

Why did deleting the Bun cache free less space than du showed?

On macOS, Bun copies packages into node_modules with clonefile. Clones share disk blocks with the cache until a file changes, so blocks a project's node_modules still uses stay on disk.