Skip to main content
Bun’s cache system stores downloaded packages to speed up installations.

Cache directory

By default, Bun stores cached packages in:
  • macOS/Linux: ~/.bun/install/cache
  • Windows: %USERPROFILE%\.bun\install\cache

Custom cache directory

Set a custom cache directory:

Via bunfig.toml

Via CLI flag

Via environment variable

Cache behavior

What gets cached

Bun caches:
  • Tarballs - Downloaded package tarballs from registries
  • Extracted packages - Unpacked package contents
  • Git repositories - Cloned git dependencies
  • Package metadata - Registry responses (manifests)

Cache structure

Packages are stored by name and version.

Cache hits

When installing a package:
  1. Bun checks if the package exists in cache
  2. If found, uses cached version (no download)
  3. If not found, downloads and adds to cache
Typical cache hit install: < 100ms per package

Disabling cache

Disable completely

Via bunfig.toml

Via CLI flag

Bypass cache temporarily

Force re-download packages:
This downloads packages even if they exist in cache.

Manifest cache

Bun also caches package metadata (manifests) from registries.

Manifest cache directory

  • macOS/Linux: ~/.bun/install/cache/manifests
  • Windows: %USERPROFILE%\.bun\install\cache\manifests

Disable manifest cache

Via bunfig.toml

Via CLI flag

Managing cache

View cache size

Example output:

Clear cache

Output:
Or manually:

View cache location

Output:

Configuration

bunfig.toml options

Advanced cache settings

CI/CD caching

GitHub Actions

Cache Bun packages between runs:

GitLab CI

Docker

Cache Bun packages in Docker:

Cache invalidation

Bun invalidates cache when:
  • Package version changes
  • Package tarball checksum changes
  • Registry URL changes
  • Bun version changes (major updates)

Manual invalidation

Force cache invalidation:
Or:

Cache sharing

Multiple projects

The cache is shared across all projects on your machine:

Multiple users

Each user has their own cache directory:
To share cache between users, use a custom cache directory:

Troubleshooting

Cache corruption

If you suspect cache corruption:

Out of disk space

If cache is too large:

Permission errors

If you get permission errors:

Slow installs despite cache

If installs are slow even with cache:
  1. Check network connectivity
  2. Verify cache isn’t disabled
  3. Check disk I/O performance
  4. Try clearing and rebuilding cache:

Performance tips

Use cache on fast storage

For best performance, place cache on SSD:

Periodic cache cleanup

Clean cache periodically to save disk space:

Cache in Docker

Use BuildKit cache mounts for fast Docker builds:
This caches packages across Docker builds.

Examples

Disable cache temporarily

Custom cache per project

Shared team cache