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

Tar cannot overwrite read-only files on Windows #936

Closed
1 of 5 tasks
mzabaluev opened this issue May 25, 2020 · 5 comments
Closed
1 of 5 tasks

Tar cannot overwrite read-only files on Windows #936

mzabaluev opened this issue May 25, 2020 · 5 comments
Assignees
Labels
Area: Common Tools investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Windows

Comments

@mzabaluev
Copy link

Describe the bug
C:\Windows\System32\tar.exe fails to remove existing files that need to be overwritten by an archive extraction, but have the read-only attribute.

Area for Triage:
Scripting and command line

Question, Bug, or Feature?:
Bug

Virtual environments affected

  • macOS 10.15
  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Windows Server 2016 R2
  • Windows Server 2019

Expected behavior
This workflow should succeed despite read-only object files present in the .git directory.

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

      - uses: actions/checkout@v2

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

      - name: Pack and unpack
        run: |
          C:\windows\System32\tar.exe -cz -f ${{ runner.temp }}\repo.tgz .
          C:\windows\System32\tar.exe -xzv -f ${{ runner.temp }}\repo.tgz

The cache action uses this tar executable in this way. tar works with these options on the Unix OSes where git also makes its object/pack files read-only, and I haven't found any tar options that could be used to force removal of read-only files specifically on Windows.

Actual behavior
Failure with "Can't unlink already-existing object" errors referring to the read-only files.

@Darleev Darleev added Area: Common Tools investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Windows and removed needs triage labels May 26, 2020
@Darleev Darleev self-assigned this May 26, 2020
@Darleev
Copy link
Contributor

Darleev commented May 26, 2020

Hello @mzabaluev,
I have reproduced the issue on agent machine, and it seems the issue in bsdtar installed on agent machine( C:\windows\System32\tar.exe ).
As a workaround for the issue, you can use tar from git directory like in an example below:

C:\"Program Files"\Git\usr\bin\tar.exe -cz -f ${{ runner.temp }}\repo.tgz .
C:\"Program Files"\Git\usr\bin\tar.exe -xzv -f ${{ runner.temp }}\repo.tgz

We will consider changing default tar directory in Windows 2019 image.

@Darleev
Copy link
Contributor

Darleev commented May 26, 2020

Current implementation of actions/cache uses tar from system32 directory.

const systemTar = ${process.env['windir']}\\System32\\tar.exe

Windows2019 image contain bsdtar 3.3.2 in this folder.
"C:\ProgramFiles\Git" folder contains tar (GNU tar) 1.32 that works for this cases.
Unfortunately, we can't replace system32 tar with GNU version because previously, it caused huge regression for a lot of customers.
I suggest to improve actions/cache to use tar that come from Git or place own tar.exe binary in Action
Also, it is possible to remove tar from C:\Windows\System32\ directory. In this case, git tar will be automatically used as default one.
If additional information or assistance is required, do not hesitate to contact us.

@mzabaluev
Copy link
Author

Hello @mzabaluev,
As a workaround for the issue, you can use tar from git directory like in an example below:

C:\"Program Files"\Git\usr\bin\tar.exe -cz -f ${{ runner.temp }}\repo.tgz .
C:\"Program Files"\Git\usr\bin\tar.exe -xzv -f ${{ runner.temp }}\repo.tgz

This fails because the tar in Git distribution does not interpret Windows path names as such. This has not changed since #480, so I guess it's not an option for the time being.

@Darleev
Copy link
Contributor

Darleev commented May 26, 2020

@mzabaluev I have tested in your test repository on a separate branch the behavior you have mentioned. I have changed a little bit your workflow file, and it works fine with the following configuration:

      - name: Pack and unpack
        run: |
          C:\"Program Files"\Git\usr\bin\tar.exe --force-local -cz -f ${{ runner.temp }}\repo.tgz .
          C:\"Program Files"\Git\usr\bin\tar.exe --force-local -xzv -f ${{ runner.temp }}\repo.tgz

Could you please verify on your side and provide a result?

@mzabaluev
Copy link
Author

@Darleev Thank you, the --force-local option makes it work.

Closing, as it's not reasonable to expect the Windows-provided tool in its standard location to be replaced with something that behaves differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Common Tools investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Windows
Projects
None yet
Development

No branches or pull requests

2 participants