fix(cache): resolve pub cache path from PUB_CACHE for cross-OS runners - #2
Conversation
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
|
cc @Project516 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe action now uses ChangesPub cache configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@action.yml`:
- Line 33: Correct the documented Linux/macOS pub cache path from ~/pub-cache to
~/.pub-cache in action.yml lines 33-33 and README.md lines 44-44; update both
descriptions consistently without changing surrounding content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8caa2330-cdfc-4829-8e22-df89abea30ec
📒 Files selected for processing (2)
README.mdaction.yml
Flutter's default PUB_CACHE on Linux and macOS is ~/.pub-cache, not ~/pub-cache. Fix both descriptions to match. Addresses CodeRabbit review feedback.
Project516
left a comment
There was a problem hiding this comment.
Verified the finding against current code — still valid. Flutter's default PUB_CACHE on Linux/macOS is ~/.pub-cache, not ~/pub-cache; both action.yml and README.md had it wrong. Fixed both descriptions consistently (commit 15f445c). YAML re-validated with yaml.safe_load. Docstring coverage is not applicable — changed files are YAML and README, no functions.
On behalf of @Project516
Problem
The
Cache pubstep hardcodedpath: ~/.pub-cache:The cache key branches on
${{ runner.os }}, so the step is clearly meant to run on more than one runner OS. But Flutter does not write its packages to~/.pub-cacheon Windows. On awindows-latestjob,flutter pub getpopulates%LOCALAPPDATA%\Pub\Cache, so this step was saving and restoring a directory Flutter never touches. The pub restore was a no-op there every run, and a stale~/.pub-cachesnapshot kept getting written back into the cache.Fix
subosito/flutter-action@v2 already exports
PUB_CACHEto the job environment, pointing at the directoryflutter pub getactually populates on the current runner:~/pub-cache(that is,$HOME/.pub-cache)%LOCALAPPDATA%\Pub\CacheThis change caches that path directly:
Because env vars written to
GITHUB_ENVby a prior step are available to later steps in the same job, theInstall Flutterstep'sPUB_CACHEis already set by the timeCache pubevaluates itspath.Behavior
PUB_CACHEequals~/.pub-cache, so this is a no-op there.~/.pub-cache, so the pub restore starts hitting onwindows-latest.Verification
action.ymlparses as valid YAML (yaml.safe_load).cappy-dev <cappy-dev@users.noreply.github.com>.Summary by CodeRabbit
New Features
Documentation