From 20a31f93b9d9913821afc24023a7d0c7655e2fc1 Mon Sep 17 00:00:00 2001 From: cappy-dev Date: Sun, 2 Aug 2026 08:15:53 +0000 Subject: [PATCH 1/2] fix(cache): resolve pub cache path from PUB_CACHE for cross-OS runners The Cache pub step hardcoded ~/.pub-cache, which is the right directory on Linux and macOS but not on Windows runners, where Flutter writes pub packages to %LOCALAPPDATA%\Pub\Cache. The cache key is keyed on runner.os, so the step was cross-OS in intent but cached a directory Flutter never touches on Windows, meaning windows-latest jobs silently missed the pub cache every time. subosito/flutter-action@v2 already exports PUB_CACHE to the job environment pointing at the directory flutter pub get populates on the current runner (~/.pub-cache on Linux/macOS, the LOCALAPPDATA Pub Cache on Windows). Cache that path directly via ${{ env.PUB_CACHE }}. On Linux and macOS this is identical to ~/.pub-cache, so behavior is unchanged there; on Windows it now caches the directory flutter pub get actually uses. On behalf of @project516 --- README.md | 11 +++++++++++ action.yml | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0dcb0f1..da7f754 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,17 @@ Omit `flutter-version` to track a channel instead (default `stable`): Run it after checkout and before any `flutter` command. It replaces roughly 20 lines per job; we were carrying nine copies before extracting this. +## Caching + +The pub cache step snapshots the directory `flutter pub get` writes to on +the current runner, resolved from the `PUB_CACHE` env var that +[subosito/flutter-action](https://github.com/subosito/flutter-action) +exports for the job. That path is `~/pub-cache` on Linux and macOS and the +`LOCALAPPDATA` Pub Cache on Windows, so the same workflow caches the right +directory on every runner OS. Leave the key (`${{ runner.os }}-pub-...`) as +is for cross-OS safety: a cache built on Windows is not reused on Ubuntu, +and vice versa. + ## License AGPL-3.0 diff --git a/action.yml b/action.yml index fd7f808..29889b5 100644 --- a/action.yml +++ b/action.yml @@ -28,7 +28,14 @@ runs: - name: Cache pub uses: actions/cache@v6 with: - path: ~/.pub-cache + # subosito/flutter-action@v2 exports PUB_CACHE to the job environment, + # pointing at the directory `flutter pub get` actually populates + # (~/pub-cache on Linux and macOS, the LOCALAPPDATA Pub Cache on + # Windows). Cache that path directly so this step stays in sync with + # the SDK install step on every runner OS. Hardcoding ~/.pub-cache + # instead misses the real cache directory on Windows runners, where + # Flutter writes pub packages to %LOCALAPPDATA%\Pub\Cache by default. + path: ${{ env.PUB_CACHE }} key: ${{ runner.os }}-pub-${{ hashFiles('pubspec.lock') }} restore-keys: | ${{ runner.os }}-pub- From 15f445cdb3cd1ccab18a23863fefbd6304e719a6 Mon Sep 17 00:00:00 2001 From: project516 <138796702+Project516@users.noreply.github.com> Date: Mon, 3 Aug 2026 10:47:38 -0500 Subject: [PATCH 2/2] docs: correct Linux/macOS pub cache path to ~/.pub-cache Flutter's default PUB_CACHE on Linux and macOS is ~/.pub-cache, not ~/pub-cache. Fix both descriptions to match. Addresses CodeRabbit review feedback. --- README.md | 2 +- action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da7f754..fb05260 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Run it after checkout and before any `flutter` command. It replaces roughly The pub cache step snapshots the directory `flutter pub get` writes to on the current runner, resolved from the `PUB_CACHE` env var that [subosito/flutter-action](https://github.com/subosito/flutter-action) -exports for the job. That path is `~/pub-cache` on Linux and macOS and the +exports for the job. That path is `~/.pub-cache` on Linux and macOS and the `LOCALAPPDATA` Pub Cache on Windows, so the same workflow caches the right directory on every runner OS. Leave the key (`${{ runner.os }}-pub-...`) as is for cross-OS safety: a cache built on Windows is not reused on Ubuntu, diff --git a/action.yml b/action.yml index 29889b5..c21af1e 100644 --- a/action.yml +++ b/action.yml @@ -30,7 +30,7 @@ runs: with: # subosito/flutter-action@v2 exports PUB_CACHE to the job environment, # pointing at the directory `flutter pub get` actually populates - # (~/pub-cache on Linux and macOS, the LOCALAPPDATA Pub Cache on + # (~/.pub-cache on Linux and macOS, the LOCALAPPDATA Pub Cache on # Windows). Cache that path directly so this step stays in sync with # the SDK install step on every runner OS. Hardcoding ~/.pub-cache # instead misses the real cache directory on Windows runners, where