Skip to content

Restoring cache on Windows created on Linux silently fails if GNU tar is not on Windows Path #576

Closed

Description

@sebthom

I setup a CI pipeline where a linux job downloads files from a remote repository and puts them into a cache.
Then jobs on different platforms (linux, macos, windows) are started that reference the cache.
All jobs receive a cache hit but on Windows the downloaded cache archive is empty.

It looks like on Windows the filename cache.tgz is expected but on Linux and MacOS cache.tzst is used.

These are the logs I get for the jobs using the cache:

Linux:
------
Run actions/cache@v2
  with:
    path: .extensions
    key: extensions-802592892
    restore-keys: extensions-
Received 129569068 of 129569068 (100.0%), 136.2 MBs/sec
Cache Size: ~124 MB (129569068 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/8f4a3549-d2e9-4b85-a044-4c0d37f47d60/cache.tzst -P -C /home/runner/work/vitcode/vitcode
Cache restored successfully
Cache restored from key: extensions-802592892

MacOS:
------
Run actions/cache@v2
  with:
    path: .extensions
    key: extensions-802592892
    restore-keys: extensions-
Received 129569068 of 129569068 (100.0%),  45.9 MBs/sec
Cache Size: ~124 MB (129569068 B)
/usr/local/bin/gtar --use-compress-program zstd -d -xf /Users/runner/work/_temp/d133514d-3d07-4e10-8844-14d51d463fff/cache.tzst -P -C /Users/runner/work/vitcode/vitcode --delay-directory-restore
Cache restored successfully
Cache restored from key: extensions-802592892

Windows:
--------
Run actions/cache@v2
  with:
    path: .extensions
    key: extensions-802592892
    restore-keys: extensions-
Received 30 of 30 (100.0%), 0.0 MBs/sec
Cache Size: ~0 MB (30 B)
C:\Windows\System32\tar.exe -z -xf D:/a/_temp/7133fe6d-5fa6-462d-a494-8faa9cdd0b31/cache.tgz -P -C D:/a/vitcode/vitcode
Cache restored successfully
Cache restored from key: extensions-802592892

Pseudo pipeline config:

name: Build

jobs:
  download-extensions:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v2
      with:
        path: .extensions
        key: extensions-${{ github.run_id }}
        restore-keys: extensions-
    - name: "Downloading Extensions"
      shell: bash
      run: ... # execute commands that download files to ./.extensions

  build-on-linux:
    runs-on: ubuntu-latest
    needs: [ download-extensions ]
    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v2
      with:
        path: .extensions
        key: extensions-${{ github.run_id }}
    - name: "Build"
      # ... build software

  build-on-macos:
    runs-on: macos-latest
    needs: [ download-extensions ]
    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v2
      with:
        path: .extensions
        key: extensions-${{ github.run_id }}
    - name: "Build"
      # ... build software

  windows-amd64:
    runs-on: macos-latest
    needs: [ download-extensions ]
    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v2
      with:
        path: .extensions
        key: extensions-${{ github.run_id }}
    - name: "Build"
      # ... build software

Activity

  1. sebthom commented on May 2, 2021

    @sebthom
    Author

    As a workaround I am now adding the GNU tar to the PATH before downloading the cache on windows:

      windows-amd64:
        runs-on: macos-latest
        needs: [ download-extensions ]
        steps:
        - name: "Use GNU tar instead BSD tar"
          shell: cmd
          run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
        - uses: actions/checkout@v2
        - uses: actions/cache@v2
          with:
            path: .extensions
            key: extensions-${{ github.run_id }}
        - name: "Build"
          # ... build software
  2. rfay commented on May 6, 2021

    @rfay

    Thanks for this. My solution (on self-hosted Windows runner) was to put C:\Program Files\Git\usr\bin early in the system path on the Windows machine and restart the runner service.

    I also had to install zstd.exe in C:\Program Files\Git\usr\bin to get it to work.

    @sebthom since you sorted this out, could you please retitle and add to the OP what you learned? A title like "restoring cache fails if GNU tar is not the default tar in $PATH" would help people sort this out.

  3. changed the title [-]Sharing cache between Linux/MacOS and Windows is not working[/-] [+]Restoring cache on Winodws created on Linux silently fails if GNU tar is not on Windows Path[/+] on May 6, 2021
  4. changed the title [-]Restoring cache on Winodws created on Linux silently fails if GNU tar is not on Windows Path[/-] [+]Restoring cache on Windows created on Linux silently fails if GNU tar is not on Windows Path[/+] on May 10, 2021
  5. github-actions commented on May 5, 2022

    @github-actions

    This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

  6. rfay commented on May 5, 2022

    @rfay

    Since this hasn't been addressed... it needs to stay alive.

  7. Phantsure commented on May 11, 2022

    @Phantsure
    Contributor

    @rfay You can't use cache created on Linux (using GNU tar) on windows (using BSD tar) as BSD can't be used to untar file created by GNU tar, and vice-versa.
    Can you confirm if the cache restored on windows is never created on windows, i.e. by using the same key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions