# Is it safe to delete ~/.pub-cache?

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

## The short answer

- **Yes.** It’s pub’s system cache of packages downloaded for your Dart and Flutter projects. Clearing it also removes tools you activated with `dart pub global activate`, so note those first.
- **What it costs you:** each project needs `flutter pub get` (or `dart pub get`) again before it builds.
- **Does it come back?** Yes, package by package, as projects fetch them.
- SiftMac’s verdict: Rebuilds

## 1. What’s in ~/.pub-cache

When a project runs `pub get`, pub downloads its dependencies into one system cache shared by every project, and each project refers to the packages there. Inside you’ll find:

- `hosted`: packages from pub.dev (in `hosted/pub.dev`) and any other package server, one folder per package version.
- `git`: packages that come from Git repositories, if your projects use any.
- `bin`: launch scripts for command-line tools you activated globally.
- A few small bookkeeping files and folders.

The Flutter SDK keeps its own cache of engine and tool files inside the SDK folder, filled by `flutter precache` and Flutter itself. That one belongs to Flutter, not to pub, and isn’t part of this folder.

## 2. Where it is

```
~/.pub-cache
```

That’s `$HOME/.pub-cache` on macOS. Setting `PUB_CACHE` puts it somewhere else, for example on a bigger drive.

## 3. How big it gets

Every version of every package a project fetched stays, so it grows with the number of projects and upgrades over time rather than with what you use today:

```
du -sh ~/.pub-cache
du -sh ~/.pub-cache/hosted/*
```

## 4. How to clear it

1. List your global tools so you can activate them again later.
2. Stop running apps and IDE builds.
3. Clear the cache. Pub asks first, warning that everything inside will go and that you’ll have to run `pub get` again in each project; `--force` skips the question.

```
dart pub global list
flutter pub cache clean
```

`flutter pub cache clean` and `dart pub cache clean` do the same thing, since `flutter pub` runs Dart’s pub. `dart pub cache repair` is different: it reinstalls every package in the cache and frees nothing.

### Build folders in projects

Each Flutter project also has `build` and `.dart_tool` folders. `flutter clean` deletes both, and the next build makes them again:

```
cd ~/Projects/my_app
flutter clean
```

## 5. What happens afterwards

- Projects can’t build or be analysed until `flutter pub get` has run in each one.
- `pubspec.lock` keeps every package at the same version, so the fetch gives you what you had.
- Globally activated tools stop working until you run `dart pub global activate <package>` again.
- The Flutter SDK, your simulators and emulators aren’t affected.

## Questions

### Can I delete ~/.pub-cache in Finder?

Yes, with nothing running; that’s what `pub cache clean` does for you. Dart’s docs say that with an SDK too old to have the `clean` command, you delete the `PUB_CACHE` folder by hand.

### Will clearing the pub cache delete my Flutter SDK?

No. The SDK and its own cache live in the folder where you installed Flutter. Only downloaded packages and global tools go.

### What does flutter clean delete?

Only the project’s `build` and `.dart_tool` folders. It leaves `~/.pub-cache` alone, and the next build regenerates both.

### Can I move the pub cache to an external drive?

Yes: set `PUB_CACHE` to the new folder in your shell profile, then run `flutter pub get` in each project so it refers to packages in the new place.

## How SiftMac handles it

SiftMac doesn’t clear `~/.pub-cache`. Under Developer files it lists `build` and `.dart_tool` folders next to a `pubspec.yaml`, in projects you haven’t changed for 1, 3 or 6 months, the same folders `flutter clean` removes, and it leaves the Flutter SDK’s own folders alone.

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

## Sources

- [Dart: dart pub cache](https://dart.dev/tools/pub/cmd/pub-cache)
- [Dart: pub environment variables (PUB_CACHE)](https://dart.dev/tools/pub/environment-variables)
- [Dart: dart pub global](https://dart.dev/tools/pub/cmd/pub-global)
- [Flutter: the flutter command (clean, pub, precache)](https://docs.flutter.dev/reference/flutter-cli)

## Related

- [Is it safe to delete the Android SDK folder?](https://siftmac.com/safe-to-delete/android-sdk)
- [Is it safe to delete Gradle’s caches in ~/.gradle?](https://siftmac.com/safe-to-delete/gradle-caches)
- [Is it safe to delete CocoaPods’ cache and a project’s Pods folder?](https://siftmac.com/safe-to-delete/cocoapods-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/flutter-pub-cache
