question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

run-vcpkg fails when using gnu tar for actions/cache on Windows (for zstd support)

See original GitHub issue

actions/cache falls back to tar with gzip if it can’t find gnu tar. This is the default expected behavior on Windows due to the default configuration. However, it is possible to make zstd compressed caches if gnu tar is inserted into $PATH ahead of bsdtar. The recommended workaround is to prepend to path in a step before the actions/cache step. Eg. https://github.com/actions/cache/issues/888

- if: ${{ runner.os == 'Windows' }} # Workaround required when using cache action across operating systems. See https://github.com/actions/cache/issues/591
 name: Use GNU tar not BSD tar
 shell: cmd
 run: |
   echo "Adding GNU tar to PATH"
   echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"

This works fine with regular actions/cache

Cache Size: ~536 MB (561804504 B)
"C:\Program Files\Git\usr\bin\tar.exe" --use-compress-program "zstd -d" -xf D:/a/_temp/dad43f6a-[26](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:12:27)d7-4781-b681-f7c0a747994a/cache.tzst -P -C D:/a/Cataclysm-DDA/Cataclysm-DDA --force-local
Cache restored successfully
...
Post job cleanup.
"C:\Program Files\Git\usr\bin\tar.exe" --posix --use-compress-program "zstd -T0" -cf cache.tzst --exclude cache.tzst -P -C D:/a/Cataclysm-DDA/Cataclysm-DDA --files-from manifest.txt --force-local
Cache Size: ~536 MB (561930170 B)
Cache saved successfully
Cache saved with key: ccache-master-Windows-msvc--[2](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:42:2)02208260[5](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:42:5)28

But it causes run-vcpkg to fail on cache creation (in my configuration, at least)

Saving a new cache entry, because primary key was missed or a fallback restore key was hit.
  Caching paths: 'D:/a/Cataclysm-DDA/b/vcpkg_cache,D:\a\Cataclysm-DDA\b\vcpkg,!D:\a\Cataclysm-DDA\b\vcpkg\installed,!D:\a\Cataclysm-DDA\b\vcpkg\vcpkg_installed,!D:\a\Cataclysm-DDA\b\vcpkg\packages,!D:\a\Cataclysm-DDA\b\vcpkg\buildtrees,!D:\a\Cataclysm-DDA\b\vcpkg\downloads'
  Saving cache with primary key 'runnerOS=win1920220821.1-vcpkgGitCommit=bd1ef2df[4](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:43:4)6303989eeb048eb7aa9b816aa4636[5](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:43:5)e_appendedKey=f28feabd[6](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:43:6)af844c19026d6a94ee11b62bdd22a040[7](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:43:7)09231070ad37a3f[8](https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true#step:43:8)28360d-x64-1' ...
  "C:\Program Files\Git\usr\bin\tar.exe" --use-compress-program "zstd -T0" -cf cache.tzst -P -C D:/a/Cataclysm-DDA/Cataclysm-DDA --files-from manifest.txt --force-local
  /usr/bin/tar: ..\b\vcpkg_cache: Cannot stat: No such file or directory
  /usr/bin/tar: ..\b\vcpkg: Cannot stat: No such file or directory
  /usr/bin/tar: Exiting with failure status due to previous errors
  Warning: Tar failed with error: The process 'C:\Program Files\Git\usr\bin\tar.exe' failed with exit code 2

I tried forking run-vcpkg and manually upgrading the @actions/cache dependency to ^3.0.4 but it made no effect on the outcome.

The run-vcpkg configuration we are using is

    - name: Restore artifacts, or run vcpkg, build and cache artifacts
      uses: lukka/run-vcpkg@main
      id: runvcpkg
      with:
        # run-vcpkg tries to hash vcpkg.json but complans if it finds more than one.
        # That said, we also have our custom vcpkg_triplets to hash, so we keep everything the same.
        appendedCacheKey: ${{ hashFiles( 'msvc-full-features/vcpkg.json', '.github/vcpkg_triplets/**' ) }}-x64-1
        vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
        # We have to use at least this version of vcpkg to include fixes for yasm-tool's
        # availability only as an x86 host tool. Keep it in sync with the builtin-baseline
        # field in vcpkg.json. Caching happens as a post-action which runs at the end of
        # the whole workflow, after vcpkg install happens during msbuild run.
        vcpkgGitCommitId: 'bd1ef2df46303989eeb048eb7aa9b816aa46365e'

And here is a sample workflow you can look at which demonstrates the functional and nonfunctional behavior: https://github.com/akrieger/Cataclysm-DDA/runs/8030290576?check_suite_focus=true

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
akriegercommented, Sep 2, 2022

It’s working great, thanks again!

1reaction
lukkacommented, Aug 28, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Select GNU tar for caching if available on hosted runners #552
Caching correctly selects GNU tar on Windows 2016 runners, since (2) shows up on the PATH. Windows 2019 runners use BSD tar because...
Read more >
[Bug-tar] added support for lz4 and zstd
Hello, I've created a patch for tar, which adds support for lz4 and zstd compression. Both compression tools have become increasingly popular ...
Read more >
Apparently this is how to use Zstd with tar if anyone else was ...
BSD tar on my Mac (running 10.15.2) has -a for tarfile creation (-c mode); it always autodetects the compression format in extraction mode...
Read more >
GNU Tar 1.31 Released With Zstd Support - Phoronix
As the first update to the GNU Tar program in more than one year, Tar 1.31 is out today and it has support...
Read more >
How to unzip a tar.gz file - Opensource.com
Its name implies it's a zip utility, but it also works with tar ... an actual tar utility on Windows, GNU tar is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found