actions / actions/toolkit

Windows tar cannot overwrite read-only files

Open
#479 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug cache
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
C:\Windows\System32\tar.exe fails when an archive extraction needs to overwrite existing files with the read-only attribute. This creates problems in the cache action: https://github.com/actions/cache/issues/198

To Reproduce
Trigger this GitHub workflow two times:

on: push

jobs:
  test:
    runs-on: windows-latest
    steps:

      - uses: actions/checkout@v2

      - name: List read-only files
        run: Get-ChildItem .git -Recurse -Attributes ReadOnly

      - uses: actions/cache@v2
        with:
          key: break-me
          path: .git

The cache action fails on the second run, with tar reporting "Can't unlink already-existing object" errors referring to the read-only files.

Expected behavior

On the second run, the cache action should restore from the key with no errors.

Additional context
The system tar is selected in preference to GNU tar, which works as expected when --force-local option is used. GNU tar is installed in the Windows virtual environment as part of the Git toolkit and its full path name is "C:\Program Files\Git\usr\bin\tar.exe".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/cache/src/internal/tar.ts, especially the system-tar preference, then reproduce the provided Windows workflow twice on windows-latest. Compare the system tar and GNU tar behavior described in the issue; done means the second cache restore completes without "Can't unlink already-existing object" errors when read-only files are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github-actions, typescript
Domain
ci-cd, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.