cache: Linux -> Mac & enableCrossOsArchive -> Cache not found for input keys

When creating a simple cache of downloaded content in my Linux steps, and caching it, each Linux machine has no problem mounting the created cache and reusing the content.

When the workflow gets to the OSX machine, it does not register a cache hit, and instead creates a new cache instance with the identical key.

Config:

Linux Machines (happy to use the cache):

   - name: Ansible Lint -- Mount Ansible Cache
      uses: actions/cache@v3
      with:
        enableCrossOsArchive: true
        key: ansible-${{ hashFiles('./template/{{cookiecutter.profile_slug}}/profile/requirements.yml') }}-${{ env.CACHE_TTL }}
        path: ansible_cache

OSX Machine (creates it’s own cache):

    - name: Apply Profile -- Mount Ansible Cache
       uses: actions/cache@v3
       with:
         enableCrossOsArchive: true
         key: "ansible-${{ hashFiles('./template/{{cookiecutter.profile_slug}}/profile/requirements.yml') }}-${{ env.CACHE_TTL }}"
          path: ansible_cache

Am I assuming functionality that does not exist?

Example Workflow Run: https://github.com/osx-provisioner/profile-generator/actions/runs/4197900167/jobs/7280858264

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 8
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Here’s a temporary workaround for both Windows and macOS:

      # https://github.com/actions/toolkit/issues/1341
      - name: Downgrade zstd on Windows
        if: runner.os == 'Windows'
        run: |
          Invoke-WebRequest https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-v1.5.2-win64.zip -OutFile $env:RUNNER_TEMP\zstd.zip
          Expand-Archive $env:RUNNER_TEMP\zstd.zip -DestinationPath $env:RUNNER_TEMP
          Add-Content $env:GITHUB_PATH "$env:RUNNER_TEMP\zstd-v1.5.2-win64"
      - name: Downgrade zstd on macOS
        if: runner.os == 'macOS'
        run: |
          brew uninstall --ignore-dependencies zstd
          git -C "$(brew --repo homebrew/core)" checkout d3f04bd Formula/zstd.rb
          brew install zstd

(see e.g. commit https://github.com/kleisauke/wasm-vips/commit/d475fb3b61f5b458fc444943dd035c1b42827f75)

I’ve added this step to my workflow as a temporary workaround

    # zstd 1.5.4 broke actions/toolkit https://github.com/actions/toolkit/issues/1341
    - if: runner.os == 'Windows'
      run: |
        if zstd --version | grep -q '1.5.[4-9]'; then
          choco install zstandard --version 1.5.0
          echo 'C:\ProgramData\chocolatey\bin'>>"$GITHUB_PATH"
        fi
      shell: bash

@rohanKanojia That won’t be helpful, due to the fact, that the hosted runner needs to get downgraded in the version of zstd until the issue is fixed here.

You can do this on hosted runner (Ubuntu):

- name: Install Zstd
  run: sudo apt-get update && sudo apt-get install zstd=1.4* && sudo rm -rf /usr/local/bin/zstd

I only tested it on ubuntu-20.04, but ubuntu-latest (22.04) should also have an older zstd version.

The issue need to be fixed here: https://raw.githubusercontent.com/actions/cache/main/dist/restore-only/index.js Line 1182:

function getCompressionMethod() {
    return __awaiter(this, void 0, void 0, function* () {
        const versionOutput = yield getVersion('zstd');
        const version = semver.clean(versionOutput);
        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {

@kleisauke mentioned the corresponding commit on zstd, thanks for that!

It looks like most (all?) of the GitHub hosted runners have updated to zstd 1.5.4, so they’re working together by falling back to gzip instead. However, we have some self hosted runners still on zstd 1.5.0, so now I’m using this workaround on Linux too.

    - if: runner.os == 'Linux'
      run: |
        if zstd --version | grep -q 'Zstandard CLI'; then
          printf '#!/bin/sh\n'"$(which zstd)"' "$@" | sed "s/Zstandard CLI/zstd command line interface/g"' > "$RUNNER_TEMP/zstd"
          chmod +x "$RUNNER_TEMP/zstd"
          echo "$RUNNER_TEMP">>"$GITHUB_PATH"
        fi
      shell: bash

… commit https://github.com/facebook/zstd/commit/9c93dd71cdb301595a8a9e364348967a173c010c seems to be the culprit (released in zstd 1.5.4)