Flutter "pub get failed" - Connection & Cache Errors in CI
Pub failed to fetch packages from pub.dev. Unlike version-solving failures, this is a download/cache problem - a transient network error or a corrupt local pub cache - and usually clears on retry or a cache repair.
What this error means
flutter pub get fails with a connection-closed, timeout, or "Hash mismatch"/"Failed to extract" error while downloading. Re-running often works, and repairing the pub cache fixes a corrupt download.
Connection closed while receiving data, package:dio.
pub get failed
Failed to extract package:image to cache: hash mismatch.Common causes
Transient pub.dev network failure
A dropped connection or timeout while downloading a package. These are flaky and unrelated to your constraints.
Corrupt or partial pub cache
A previous interrupted download left a bad archive in ~/.pub-cache, so extraction fails with a hash mismatch until the cache is repaired.
How to fix it
Retry, then repair the cache
Retry the fetch; if a hash mismatch persists, repair the cache to re-download corrupt entries.
flutter pub get || (dart pub cache repair && flutter pub get)Cache the pub cache between runs
- uses: actions/cache@v4
with:
path: ~/.pub-cache
key: pub-${{ hashFiles('pubspec.lock') }}Use a mirror for restricted networks
On networks that cannot reach pub.dev directly, point pub at an internal mirror.
export PUB_HOSTED_URL=https://pub.your-mirror.example.com
flutter pub getHow to prevent it
- Cache
~/.pub-cachekeyed onpubspec.lock. - Wrap
pub getwith apub cache repairfallback for corruption. - Use an internal mirror for high-volume or restricted pipelines.