Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@actions/cache fails on Windows when GNU tar from MSYS2 is in PATH #632

Closed
eregon opened this issue Nov 12, 2020 · 4 comments · Fixed by #670
Closed

@actions/cache fails on Windows when GNU tar from MSYS2 is in PATH #632

eregon opened this issue Nov 12, 2020 · 4 comments · Fixed by #670
Labels
bug Something isn't working

Comments

@eregon
Copy link

eregon commented Nov 12, 2020

Describe the bug

When C:\msys64\usr\bin is in the path on Windows, and using @actions/cache, I noticed that cache saving always fails:
ruby/setup-ruby#102

https://github.com/ruby/setup-ruby/runs/1370892940?check_suite_focus=true

  Saving cache
  C:\msys64\usr\bin\tar.exe --posix --use-compress-program "zstd -T0" -cf cache.tzst -P -C D:/a/setup-ruby/setup-ruby --files-from manifest.txt --force-local
  /usr/bin/tar: vendor\bundle: 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:\msys64\usr\bin\tar.exe' failed with exit code 2

The problem seems to be that the cache paths written to manifest.txt use \\ and not /, which I would think GNU tar expects.
On https://github.com/eregon/setup-ruby/runs/1392737782?check_suite_focus=true#step:3:100 we can see the cache paths written to manifest.txt is ["vendor\\bundle"] but it should most likely uses / as separator for GNU tar.

To Reproduce

Minimal repro using actions/cache:

name: Test
on: [push]
jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu, macos, windows ]
    runs-on: ${{ matrix.os }}-latest
    steps:
      - run: echo "C:\msys64\usr\bin" >> $GITHUB_PATH
        shell: bash

      - uses: actions/cache@v2
        with:
          path: top/foo
          key: ${{ runner.os }}-debug-cache1

      - run: ls -l
        shell: bash

      - name: Generate files
        run: |
          mkdir -p top/foo
          echo hello > top/foo/bar.txt
        shell: bash

https://github.com/eregon/setup-ruby-test/runs/1392827825?check_suite_focus=true#step:10:3

C:\msys64\usr\bin\tar.exe --posix --use-compress-program "zstd -T0" -cf cache.tzst -P -C D:/a/setup-ruby-test/setup-ruby-test --files-from manifest.txt --force-local
/usr/bin/tar: top\foo: 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:\msys64\usr\bin\tar.exe' failed with exit code 2

Full repro using the @actions/cache package:

    - runs-on: windows-latest
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.7
        bundler-cache: true

Expand the bundle install group of ruby/setup-ruby@v1.

Expected behavior
It should save the cache successfully.

@eine
Copy link

eine commented Nov 24, 2020

See related discussion in November 24, 2020 3:28 PM:

well, calling cygwin tools with Windows paths is a bit of a luck thing.. they weren't programmed for that and none of those scenarios are tested
From what I understand if the paths aren't touched and passed through to the "posix API" then things work fine.. if there is any path processing otherwise your best bet is to use /, relative paths etc..
tar also has a --force-local option which disables some paths checks, see msys2/MSYS2-packages#1286 (comment)
So I'd try using "/" only in the input file and "--force-local"

using cygpath for writting processed path to a file which is then to be read by tar; but not having any issue with CLI args


they could just download it in the action
If I were github I'd look into libarchive/libarchive#1419

@eregon
Copy link
Author

eregon commented Nov 24, 2020

I think replacing \ by / in cache paths would work fine. I would have tested it myself, but not quite sure how to pick my changes as an npm package (either in the ruby/setup-ruby or actions/cache action).

eregon added a commit to eregon/setup-ruby that referenced this issue Dec 12, 2020
eregon added a commit to eregon/setup-ruby that referenced this issue Dec 12, 2020
@eregon
Copy link
Author

eregon commented Dec 12, 2020

Thank you for fixing this, @aiqiaoy, I can confirm it works now :)

egor-tensin added a commit to egor-tensin/cmake-common that referenced this issue Mar 14, 2021
actions/cache@v2 doesn't work on windows-2016 images, since those
contain the GNU tar, which cannot work with \ as path separator.  This
was fixed in package @actions/cache v1.0.5, which is used by action
actions/[email protected] [1][2].

In addition, it simply couldn't find tar.exe on those images thanks to
my action cleanup-path, which removed the corresponding directory (I
think it was Git's bin/) from PATH.  It worked for windows-2019 images
thanks to them containing tar.exe in System32.  Solved by turning
cleanup-path into a JavaScript action with a "post" step, which restores
the original PATH value.

[1]: actions/runner-images#480
[2]: actions/toolkit#632
@jonashackt
Copy link

If someone stumbles upon this like me: simply pin the version to the latest v2.1.4 - as only this ships the fix #670 - and there's an open issue actions/cache#528 that using the v2 currently points to v2.1.3, which doesn't have the fix on board. See https://stackoverflow.com/a/66870003/4964553 also. With the pinned v2.1.4 we got our Windows caching working https://github.com/codecentric/spring-boot-admin/runs/2226590004?check_suite_focus=true

ccoltx added a commit to codecentric/spring-boot-admin that referenced this issue Mar 30, 2021
Cache maven repository to decrease build times (see #1677 )

* Using latest cache action release explicitly (see egor-tensin/cmake-common@eca875b and actions/toolkit#632)

Co-authored-by: Jonas Hecht <[email protected]>
adamsbusiness pushed a commit to adamsbusiness/spring-admin that referenced this issue Apr 24, 2021
Cache maven repository to decrease build times (see #1677 )

* Using latest cache action release explicitly (see egor-tensin/cmake-common@eca875b and actions/toolkit#632)

Co-authored-by: Jonas Hecht <[email protected]>
ejavexpert added a commit to ejavexpert/java-spring-boot-admin that referenced this issue Mar 25, 2022
Cache maven repository to decrease build times (see #1677 )

* Using latest cache action release explicitly (see egor-tensin/cmake-common@eca875b and actions/toolkit#632)

Co-authored-by: Jonas Hecht <[email protected]>
KingSize0319 added a commit to KingSize0319/spring-boot-admin that referenced this issue Feb 6, 2023
Cache maven repository to decrease build times (see #1677 )

* Using latest cache action release explicitly (see egor-tensin/cmake-common@eca875b and actions/toolkit#632)

Co-authored-by: Jonas Hecht <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants