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

Windows/ Powershell error: Expand-Archive : is not a supported archive file format. .zip is the only supported archive file format. #91

Closed
irnbrux opened this issue Oct 7, 2023 · 11 comments

Comments

@irnbrux
Copy link

irnbrux commented Oct 7, 2023

Hi,

i get the following error using

  • name: Install CMake and Ninja
    uses: lukka/[email protected]
    with:
    useLocalCache: true
    useCloudCache: false
    cmakeVersion: "~3.27.0"
    ninjaVersion: latest

log:
useCloudCache:false
useLocalCache:true
user defined cmake version:~3.27.0
user defined ninja version:latest
cmake version:~3.27.0
ninja version:latest
::group::Computing cache key from the downloads' URLs
Cache key: '507572093'.
Local install root: 'C:\Users\User.cache\act\8c275a1a4fda57b3\tmp\507572093''.
::endgroup::
::group::Restoring from local GitHub runner cache using key '507572093'
Local cache miss.
::endgroup::
::group::Downloading and extracting CMake
[command]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:\Users\User.cache\act\8c275a1a4fda57b3\tmp\ad76d5b6-c455-4ab6-810f-4a4c64dce49b' -DestinationPath 'C:\Users\User.cache\act\8c275a1a4fda57b3\tmp\507572093' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\User.cache\act\8c275a1a4fda57b3\tmp\ad76d5b6-c455-4ab6-810f-4a4c64dce49b', 'C:\Users\User.cache\act\8c275a1a4fda57b3\tmp\507572093', $true) }"
Expand-Archive : is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210

  • ... Ignore)) { Expand-Archive -LiteralPath 'C:\Users\User.cache\act\8c2 ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:String) [Expand-Archive], IOException
    • FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

::endgroup::
Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
at ExecState._setResult (C:\Users\User.cache\act\8c275a1a4fda57b3\act\actions\[email protected]\dist\index.js:5801:25)
at ExecState.CheckComplete (C:\Users\User.cache\act\8c275a1a4fda57b3\act\actions\[email protected]\dist\index.js:5784:18)
at ChildProcess. (C:\Users\User.cache\act\8c275a1a4fda57b3\act\actions\[email protected]\dist\index.js:5678:27)
at ChildProcess.emit (node:events:514:28)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5)
::error::get-cmake action execution failed: 'Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1'

@lukka
Copy link
Owner

lukka commented Oct 7, 2023

@irnbrux this looks like identical to this problem: #74
Are you using a self-hosted action runner? Looks like there is a difference in the environment between the GH hosted runner and the self-hosted runner, and it would be nice if we find out what it is, and how to insert the fix in the action itself.

@irnbrux
Copy link
Author

irnbrux commented Oct 7, 2023

Hi,

it is identical to #74 indeed. The cause is to use the expand cmdlet on a file that does not have a .zip file extension. When you rename the file first (as part of the action) to have a .zip file extension, it will work I guess. At least this is the behavior if I invoke the commands manually.

Cheers
Brian

@lukka
Copy link
Owner

lukka commented Oct 7, 2023

@irnbrux this should be the root cause: actions/toolkit#1179

lukka added a commit that referenced this issue Oct 7, 2023
lukka added a commit that referenced this issue Oct 7, 2023
@lukka
Copy link
Owner

lukka commented Oct 7, 2023

@irnbrux you may try this version and report back: uses: lukka/get-cmake@dev/fix91

@irnbrux
Copy link
Author

irnbrux commented Oct 10, 2023

So with fix91 I can see the zip gets extracted correctly, however the process just keeps running after extraction and never completes. I need to investigate further:

useCloudCache:false useLocalCache:false user defined cmake version:latest user defined ninja version:latest cmake version:latest ninja version:latest ::group::Computing cache key from the downloads' URLs Cache key: '507572093'. Local install root: 'C:\Users\User\.cache\act\679324afd465c947\tmp\507572093''. ::endgroup:: ::group::Downloading and extracting CMake [command]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:\Users\User\.cache\act\679324afd465c947\tmp\0d05c39a-3b7c-4607-93ac-54ef847dbfbc.zip' -DestinationPath 'C:\Users\User\.cache\act\679324afd465c947\tmp\507572093' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\User\.cache\act\679324afd465c947\tmp\0d05c39a-3b7c-4607-93ac-54ef847dbfbc.zip', 'C:\Users\User\.cache\act\679324afd465c947\tmp\507572093', $true) }"

There is nothing more after the last line ...

@irnbrux
Copy link
Author

irnbrux commented Oct 10, 2023

OK, the cmake extract does now work, however we get the same error for the ninja download as well I think:

useCloudCache:false
useLocalCache:false
user defined cmake version:latest
user defined ninja version:latest
cmake version:latest
ninja version:latest
::group::Computing cache key from the downloads' URLs
Cache key: '507572093'.
Local install root: 'C:\Users\User.cache\act\679324afd465c947\tmp\507572093''.
::endgroup::
::group::Downloading and extracting CMake
[command]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:\Users\User.cache\act\679324afd465c947\tmp\0d05c39a-3b7c-4607-93ac-54ef847dbfbc.zip' -DestinationPath 'C:\Users\User.cache\act\679324afd465c947\tmp\507572093' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\User.cache\act\679324afd465c947\tmp\0d05c39a-3b7c-4607-93ac-54ef847dbfbc.zip', 'C:\Users\User.cache\act\679324afd465c947\tmp\507572093', $true) }"
::endgroup::
::group::Downloading and extracting Ninja
[command]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:\Users\User.cache\act\679324afd465c947\tmp\a01294d2-2a5b-49f3-9a93-abca76fc5550' -DestinationPath 'C:\Users\User.cache\act\679324afd465c947\tmp\507572093' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\User.cache\act\679324afd465c947\tmp\a01294d2-2a5b-49f3-9a93-abca76fc5550', 'C:\Users\User.cache\act\679324afd465c947\tmp\507572093', $true) }"
Expand-Archive : is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210

  • ... Ignore)) { Expand-Archive -LiteralPath 'C:\Users\User.cache\act\679 ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:String) [Expand-Archive], IOException
    • FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

::endgroup::
Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
at ExecState._setResult (C:\Users\User.cache\act\679324afd465c947\act\actions\lukka-get-cmake@dev-fix91\dist\index.js:5811:25)
at ExecState.CheckComplete (C:\Users\User.cache\act\679324afd465c947\act\actions\lukka-get-cmake@dev-fix91\dist\index.js:5794:18)
at ChildProcess. (C:\Users\User.cache\act\679324afd465c947\act\actions\lukka-get-cmake@dev-fix91\dist\index.js:5688:27)
at ChildProcess.emit (node:events:514:28)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5)
::error::get-cmake action execution failed: 'Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1'

lukka added a commit that referenced this issue Oct 11, 2023
@lukka
Copy link
Owner

lukka commented Oct 11, 2023

@irnbrux thank you for reporting back! Now the same manipulation is applied to the ninja build tool archive, you may try again, thank you!

@irnbrux
Copy link
Author

irnbrux commented Oct 16, 2023

Hi @lukka

that works for me now for cmake and ninja under Windows 11.
Thank you for the work you are doing.

Cheers
Brian

lukka added a commit that referenced this issue Oct 22, 2023
@lukka
Copy link
Owner

lukka commented Oct 23, 2023

@irnbrux thank you for testing the PR #92 ! I thought to rework the code in order to apply the fix only if strictly needed, and I'd be happy if you could still confirm this is working correctly. Then I'll merge, thank you.

@samuelpmish
Copy link

I also hit this issue on a self-hosted windows runner. After installing powershell 7 with

winget install --id Microsoft.Powershell --source winget

I still had the same issue (apparently the newer version doesn't replace the old powershell, it's just installed alongside), but switching to uses: lukka/get-cmake@dev/fix91 did seem to work for me.

lukka added a commit that referenced this issue Nov 5, 2023
@lukka
Copy link
Owner

lukka commented Nov 6, 2023

Fixed in main and latest branches.

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

3 participants