Skip to content

Tar fails on Windows after 15min due to symlink cycle #315

Closed

Description

@cjolowicz

On Windows, the cache action hangs for 15+min in the post step before failing with Cannot stat: Invalid argument. It appears to be caught in a symlink cycle, see details below. I have seen this issue consistently for a few weeks on Windows runners, on every run.

The cache action is used for the ~/.cache/pre-commit directory, which contains environments for linter tools managed by pre-commit, in this particular case a node environment for Prettier. The job output suggests that tar.exe runs into a symlink cycle:

Post job cleanup.
C:\windows\System32\tar.exe -cz -f d:/a/_temp/bcdd723a-8b44-4f20-a0cd-40818adf8d6e/cache.tgz -C C:/Users/runneradmin/.cache/pre-commit .
tar.exe: ./repobcgy0yhx/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier/node_env-default/Scripts/node_modules/prettier: Cannot stat: Invalid argument
tar.exe: Error exit delayed from previous errors.
[warning]Tar failed with error: The process 'C:\windows\System32\tar.exe' failed with exit code 1

Inspecting the cache layout locally reveals that prettier is a symlink to the directory three levels up:

$ readlink ~/.cache/pre-commit/repo2c0jl6uh/node_env-default/lib/node_modules/prettier
../../../

$ realpath ~/.cache/pre-commit/repo2c0jl6uh/node_env-default/lib/node_modules/prettier
~/.cache/pre-commit/repo2c0jl6uh

(Note that this is on a macOS machine. The directory layout should be similar on Windows, with a Scripts directory instead of lib.)

Could be related to #120

Activity

  1. yajo commented on Aug 8, 2020

    @yajo

    Same here. Just in case it helps, here is the fail log and here is the workflow code.

  2. added a commit that references this issue on Aug 8, 2020
  3. added a commit that references this issue on Aug 8, 2020
  4. dhadka commented on Aug 10, 2020

    @dhadka
    Contributor

    @yajo I tested with symbolic links and junction points. Symbolic links are handled fine, but junction points create problems for bsdtar. It looks like the Windows 2019 runners have GNU tar installed as part of msys, which can be enabled with:

        - name: Use GNU Tar from Msys
          if: ${{ runner.os == 'Windows' }}
          run: |
            echo "::add-path::C:\msys64\usr\bin"
    

    See for example: https://github.com/dhadka/test-tar-symlink/blob/master/.github/workflows/blank.yml

  5. yajo commented on Aug 13, 2020

    @yajo

    My workaround in copier-org/copier#251 had to be:

      - name: Enable msys binaries
        if: ${{ runner.os == 'Windows' }}
        run: |
          echo "::add-path::C:\msys64\usr\bin"
          rm C:\msys64\usr\bin\bash.exe
    

    Otherwise all further steps executed with shell: bash failed due to using C:\msys64\usr\bin\bash.exe instead of C:\Program Files\Git\bin\bash.EXE.

  6. yajo commented on Oct 12, 2020

    @yajo

    That one is deprecated now. Gotta use this syntax:

      - name: Enable msys binaries
        if: ${{ runner.os == 'Windows' }}
        run: |
          echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
          rm C:\msys64\usr\bin\bash.exe
    
  7. added a commit that references this issue on Sep 10, 2021
  8. github-actions commented on Dec 23, 2021

    @github-actions

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

  9. github-actions commented on Dec 29, 2021

    @github-actions

    This issue was closed because it has been inactive for 5 days since being marked as stale.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions