Where Is the Dart Pub Cache Directory?
Dart pub cache directory for hosted packages, and the PUB_CACHE override.
Last updated
Dart caches downloaded packages in a .pub-cache directory in your home, shared across every project on the machine. Each cached version keeps its source plus metadata, which is why the folder grows with every dependency you have ever tried.
The PUB_CACHE variable relocates it, the documented answer to full home drives and shared CI caches. Project lockfiles pin exact versions against this pool, so deleting the cache only costs re download time, never correctness. Globally activated packages keep their executables in the bin subfolder here too.
Where Dart stores this, by platform
~/.pub-cache
Key children include hosted archives, git checkouts and the bin folder for globally activated executables. Set PUB_CACHE in your shell rc to relocate. Project pubspec.lock files stay inside each repo.
~/.pub-cache
Same layout as Linux. Flutter projects share this cache with pure Dart ones, since both resolve hosted packages through the same variable and directory.
Frequently asked questions
how do i move the dart pub cache
Set PUB_CACHE to the new path before running dart pub get, then move the .pub-cache directory there. Every project resolves hosted packages from that variable, so one move migrates the cache. Delete and re fetch instead if versions feel stale.
is pubspec.yaml the same as the pub cache
No. pubspec.yaml declares what a project needs for collaborators, while the pub cache holds the downloaded package bodies shared across projects. Version the first, ignore the second, and let pubspec.lock pin exact versions.
Notice an outdated path? Let us know.