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

.gz is not a supported archive file format error on Windows with new version 9c1e94e0 #1721

Closed
dbronish-cfs opened this issue May 8, 2024 · 12 comments

Comments

@dbronish-cfs
Copy link

Previously (at version 0ad4b8f), it would generate this extract command, which works properly:

Extracting the archive
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\redacted.tar.gz', 'C:\actions-runner\_work\redacted')"

Now at 9c1e94e, it generates this command, which fails:

Extracting the archive
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\actions-runner\_work\redacted.tar.gz' -DestinationPath 'C:\actions-runner\_work\redacted' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\redacted.tar.gz', 'C:\actions-runner\_work\redacted', $true) }"
Expand-Archive : .gz is not a supported archive file format. .zip is the only supported archive file format.
@dbronish-cfs
Copy link
Author

In 9c1e94e, on line 7098 of dist/index.js, logic was added to attempt to use Expand-Archive, which is obviously what's failing. The previous behavior of just using ExtractToDirectory is now the fall-through behavior if Expand-Archive is not found.

Taking a step back, I'm curious why a tarball was downloaded in the first place. It looks like a zipball should be downloaded, when running on Windows. Perhaps the issue lies there.

@lmshek
Copy link

lmshek commented May 9, 2024

I got this error too. Do we have any alternatives?

@shwetayadkikar
Copy link

I have this issue too. Downgrading to v3 works.

@AdamSmith-BT
Copy link

Also seeing this issue, explictly using v4.1.4 resolves the issue for now.

@PedroMiguelFigueiredo
Copy link

PedroMiguelFigueiredo commented May 9, 2024

Same problem... also fixed by uses: actions/checkout@v4.1.4

@cory-miller
Copy link
Contributor

I reverted v4 to point to v4.1.4 while I take a look at this.

@cory-miller
Copy link
Contributor

cory-miller commented May 9, 2024

Taking a step back, I'm curious why a tarball was downloaded in the first place. It looks like a zipball should be downloaded, when running on Windows. Perhaps the issue lies there.

I'm not actually sure if it's a tarball. On Windows we should be using downloadZipballArchive from Octokit:

const download = IS_WINDOWS
? octokit.rest.repos.downloadZipballArchive
: octokit.rest.repos.downloadTarballArchive

The problem may come from the fact that the file extension was hardcoded:

const archivePath = path.join(repositoryPath, `${uniqueId}.tar.gz`)

This combined with updating the @actions/tool-cache dependency we see a change to the command used for extracting zip archives:

https://github.com/actions/toolkit/blob/ae38557bb0dba824cdda26ce787bd6b66cf07a83/packages/tool-cache/src/tool-cache.ts#L377

It seems like Expand-Archive checks the filename for .zip extension.

If that's the case, it should be as simple as main...users/cory-miller/windows-test to fix.

I don't have easy access to a Windows machine where actions/checkout won't be able to find Git. I'll look into getting one setup and try this branch against v4.1.5

@tehpsalmist
Copy link

@cory-miller Will you be submitting that PR soon? Is it waiting on a review or testing?

@cory-miller
Copy link
Contributor

@tehpsalmist delay was due to needing but not having a Windows machine without Git.exe handy. I was able to set one up and tested the change. PR is up now.

#1732

@cory-miller
Copy link
Contributor

I've created https://github.com/actions/checkout/releases/tag/v4.1.6 and cannot reproduce this issue on that tag. I'm going to do some additional testing before promoting that to v4 (I'll do that on Monday).

Feel free to try against uses: actions/checkout@v4.1.6 and reopen this if that fix did not work for your setup.

@dbronish-cfs
Copy link
Author

I testing v4.1.6 in the same environment in which I first observed this issue.

With v4.1.6, the file is a zip and the extract is successful:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\actions-runner\_work\redacted.zip' -DestinationPath 'C:\actions-runner\_work\redacted' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\redacted.zip', 'C:\actions-runner\_work\redacted', $true) }"

Looks good, thanks!

@cory-miller
Copy link
Contributor

v4 has been updated to v4.1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants
@PedroMiguelFigueiredo @shwetayadkikar @cory-miller @tehpsalmist @AdamSmith-BT @lmshek @dbronish-cfs and others