flutter-action icon indicating copy to clipboard operation
flutter-action copied to clipboard

Caching fails on MacOS runners

Open Mr-Pepe opened this issue 9 months ago • 8 comments

Use the following action on macos-latest:

- name: Install Flutter
  uses: subosito/flutter-action@v2
  with:
    channel: "stable"
    flutter-version-file: pubspec.yaml
    cache: true

Get the following error:

Cache not found for input keys: flutter-macos-stable-3.27.1-arm64-17025dd88227cd9532c33fa78f5250d548d87e9a, flutter-macos-stable-3.27.1-arm64-17025dd88227cd9532c33fa78f5250d548d87e9a
Error: The template is not valid. subosito/flutter-action/v2/action.yaml (Line: 108, Col: 14): hashFiles('**/pubspec.lock') failed. Fail to hash files under directory '/Users/runner/work/xxx',subosito/flutter-action/v2/action.yaml (Line: 109, Col: 23): hashFiles('**/pubspec.lock') failed. Fail to hash files under directory '/Users/runner/work/xxx'

There is a workaround in the related issue by explicitly providing the file to hash instead of using wildcards.

There seems to be little progress on the issue. Would it be possible to allow specifying the paths to pubspec.lock files explictily?

Mr-Pepe avatar Mar 01 '25 05:03 Mr-Pepe

is that true? i even get error on ubuntu and windows but not macos

azkadev avatar Mar 01 '25 11:03 azkadev

Actually, all can save cache except pub_cache which seems to have a problem from the default,

The point is if you want to use cache, make sure the github action is running perfectly, after that it will save the cache and when you rerun it with the same path and key, it will use the cache

azkadev avatar Mar 01 '25 17:03 azkadev

is that true? i even get error on ubuntu and windows but not macos

You should probably open a separate issue including the exact error message you are getting.

Mr-Pepe avatar Mar 02 '25 02:03 Mr-Pepe

Could be related to #300

Waxo avatar Apr 08 '25 16:04 Waxo

No updates ?

Waxo avatar Sep 01 '25 07:09 Waxo

Facing the same issue. Caches perfectly for android builds ("linux") but fails for macOS

Cache not found for input keys: flutter-macos-stable-3.24.5-arm64-dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
Cache not found for input keys: flutter-pub-macos-stable-3.24.5-arm64-dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668

In the Post steps I get

Warning: Input required and not supplied: path
Post job cleanup.
Warning: Input required and not supplied: path
Post job cleanup.

ayush-louisa avatar Nov 18 '25 08:11 ayush-louisa

hey same issue on macos here, how could we explicitly the path like @Mr-Pepe mentioned ?

tempo-riz avatar Nov 24 '25 06:11 tempo-riz

Hello,

Found out github caching is not straight forward. https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#cache-key-matching https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache

You have to cache the things in your default branch to access it from all other branch.

Image

Don't know if it helps. I got out the caching method of this package but didn't took time for now to propose some help.

name: Caching for branches

on:
  push:
    branches:
      - develop # Default branch

jobs:
  build-cache:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - uses: actions/cache@v4
        id: cache
        with:
          path: |
            /home/runner/.pub-cache
            /opt/hostedtoolcache/flutter
          key: ${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
          restore-keys: ${{ runner.os }}-

      - name: 🚀 Install flutter
        if: steps.cache.outputs.cache-hit != 'true'
        uses: subosito/flutter-action@v2
        with:
          architecture: x64
          channel: stable
          cache: false
      #          flutter-version: 3.32.8

      - name: 🛰️ Install dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: flutter pub get

And my branches PR scripts looks like this

name: Pull request (develop)


on:
  pull_request:
    branches:
      - develop

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  code-style-pr:
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v5

[...]

      - uses: actions/cache@v4
        id: cache
        with:
          path: |
            /home/runner/.pub-cache
            /opt/hostedtoolcache/flutter
          key: ${{ runner.os }}-${{ hashFiles('pubspec.lock') }}
          restore-keys: ${{ runner.os }}-

      - uses: subosito/flutter-action@v2
        with:
          architecture: x64
          channel: stable
          cache: false
          #flutter-version: 3.32.8

      - name: Setup onepub
        run: |
          export PATH="$PATH:${{ runner.tool_cache }}/flutter/pub-cache"
          dart pub global activate onepub
          export ONEPUB_TOKEN="${{ secrets.ONEPUB_TOKEN }}"
          onepub import

      - run: flutter pub get

[...]

Waxo avatar Nov 24 '25 08:11 Waxo