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

Choco is not installed on VM #7704

Closed
2 of 10 tasks
retirem opened this issue Jun 12, 2023 · 7 comments
Closed
2 of 10 tasks

Choco is not installed on VM #7704

retirem opened this issue Jun 12, 2023 · 7 comments

Comments

@retirem
Copy link

retirem commented Jun 12, 2023

Description

The first error suggests Choco could not be installed on the VM:

mp\chocolatey\chocoInstall
    azure-arm.vhd: Installing Chocolatey on the local machine
    azure-arm.vhd: Ensuring Chocolatey commands are on the path
    azure-arm.vhd: Ensuring chocolatey.nupkg is in the lib folder
==> azure-arm.vhd: New-Object : Exception calling ".ctor" with "3" argument(s): "End of Central Directory record could not be found."
==> azure-arm.vhd: At
==> azure-arm.vhd: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:934
==> azure-arm.vhd: char:23
==> azure-arm.vhd: + ... ipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -Ar ...
==> azure-arm.vhd: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
==> azure-arm.vhd:     + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
==> azure-arm.vhd:
==> azure-arm.vhd: & : The term 'C:\Users\packer\AppData\Local\Temp\chocolatey\chocoInstall\tools\chocolateyInstall.ps1' is not
==> azure-arm.vhd: recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
==> azure-arm.vhd: a path was included, verify that the path is correct and try again.
==> azure-arm.vhd: At line:541 char:3
==> azure-arm.vhd: + & $chocoInstallPS1
==> azure-arm.vhd: +   ~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ObjectNotFound: (C:\Users\packer...ateyInstall.ps1:String) [], CommandNotFoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : CommandNotFoundException
==> azure-arm.vhd:
==> azure-arm.vhd: choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
==> azure-arm.vhd: the spelling of the name, or if a path was included, verify that the path is correct and try again.
==> azure-arm.vhd: At C:\Windows\Temp\script-6486ee41-cc39-7f72-d29e-9d26efcc9284.ps1:24 char:1
==> azure-arm.vhd: + choco feature enable -n allowGlobalConfirmation
==> azure-arm.vhd: + ~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : CommandNotFoundException
==> azure-arm.vhd:
==> azure-arm.vhd: Import-Module : The specified module '\helpers\chocolateyInstaller.psm1' was not loaded because no valid module file
==> azure-arm.vhd: was found in any module directory.
==> azure-arm.vhd: At C:\Windows\Temp\script-6486ee41-cc39-7f72-d29e-9d26efcc9284.ps1:27 char:1
==> azure-arm.vhd: + Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm ...
==> azure-arm.vhd: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ResourceUnavailable: (\helpers\chocolateyInstaller.psm1:String) [Import-Module], FileNot
==> azure-arm.vhd:    FoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
==> azure-arm.vhd:
==> azure-arm.vhd: Get-ToolsLocation : The term 'Get-ToolsLocation' is not recognized as the name of a cmdlet, function, script file, or
==> azure-arm.vhd: operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
==> azure-arm.vhd: again.
==> azure-arm.vhd: At C:\Windows\Temp\script-6486ee41-cc39-7f72-d29e-9d26efcc9284.ps1:28 char:1
==> azure-arm.vhd: + Get-ToolsLocation
==> azure-arm.vhd: + ~~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ObjectNotFound: (Get-ToolsLocation:String) [], CommandNotFoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : CommandNotFoundException

Later this is the final error:

Choco-Install : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable
==> azure-arm.vhd: program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
==> azure-arm.vhd: At C:\Windows\Temp\script-6486ee41-685c-de14-5c79-9eb518ca61c4.ps1:39 char:1
==> azure-arm.vhd: + Choco-Install -PackageName docker-compose -ArgumentList "--version=$v ...
==> azure-arm.vhd: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ObjectNotFound: (choco:String) [Choco-Install], CommandNotFoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : CommandNotFoundException,Choco-Install

The whole error might relate to this error fix:
#7657

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 11
  • macOS 12
  • macOS 13
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Windows Server 2022 20230606.1

Is it regression?

Expected behavior

Creates a VHD in Azure.

Actual behavior

Fails to use Choco

Repro steps

git pull
git checkout win22/20230606.1

User service principal to create VHD in Azure.

@vpolikarpov-akvelon
Copy link
Contributor

vpolikarpov-akvelon commented Jun 12, 2023

Hi @Technomann. Could you share full build log? I assume something went wrong before the lines you have shared.

@retirem
Copy link
Author

retirem commented Jun 12, 2023

Hi @vpolikarpov-akvelon!

This was the very first error:

==> azure-arm.vhd: New-Object : Exception calling ".ctor" with "3" argument(s): "End of Central Directory record could not be found."
==> azure-arm.vhd: At
==> azure-arm.vhd: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:934
==> azure-arm.vhd: char:23
==> azure-arm.vhd: + ... ipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -Ar ...
==> azure-arm.vhd: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
==> azure-arm.vhd:     + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
==> azure-arm.vhd:
==> azure-arm.vhd: & : The term 'C:\Users\packer\AppData\Local\Temp\chocolatey\chocoInstall\tools\chocolateyInstall.ps1' is not
==> azure-arm.vhd: recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
==> azure-arm.vhd: a path was included, verify that the path is correct and try again.
==> azure-arm.vhd: At line:541 char:3
==> azure-arm.vhd: + & $chocoInstallPS1
==> azure-arm.vhd: +   ~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ObjectNotFound: (C:\Users\packer...ateyInstall.ps1:String) [], CommandNotFoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : CommandNotFoundException
==> azure-arm.vhd:
==> azure-arm.vhd: choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
==> azure-arm.vhd: the spelling of the name, or if a path was included, verify that the path is correct and try again.
==> azure-arm.vhd: At C:\Windows\Temp\script-6486ee41-cc39-7f72-d29e-9d26efcc9284.ps1:24 char:1
==> azure-arm.vhd: + choco feature enable -n allowGlobalConfirmation
==> azure-arm.vhd: + ~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : CommandNotFoundException
==> azure-arm.vhd:
==> azure-arm.vhd: Import-Module : The specified module '\helpers\chocolateyInstaller.psm1' was not loaded because no valid module file
==> azure-arm.vhd: was found in any module directory.
==> azure-arm.vhd: At C:\Windows\Temp\script-6486ee41-cc39-7f72-d29e-9d26efcc9284.ps1:27 char:1
==> azure-arm.vhd: + Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm ...
==> azure-arm.vhd: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ResourceUnavailable: (\helpers\chocolateyInstaller.psm1:String) [Import-Module], FileNot
==> azure-arm.vhd:    FoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
==> azure-arm.vhd:
==> azure-arm.vhd: Get-ToolsLocation : The term 'Get-ToolsLocation' is not recognized as the name of a cmdlet, function, script file, or
==> azure-arm.vhd: operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
==> azure-arm.vhd: again.
==> azure-arm.vhd: At C:\Windows\Temp\script-6486ee41-cc39-7f72-d29e-9d26efcc9284.ps1:28 char:1
==> azure-arm.vhd: + Get-ToolsLocation
==> azure-arm.vhd: + ~~~~~~~~~~~~~~~~~
==> azure-arm.vhd:     + CategoryInfo          : ObjectNotFound: (Get-ToolsLocation:String) [], CommandNotFoundException
==> azure-arm.vhd:     + FullyQualifiedErrorId : CommandNotFoundException

Sorry, but this is the biggest log I can get, other parts are confidential.

@vpolikarpov-akvelon
Copy link
Contributor

vpolikarpov-akvelon commented Jun 12, 2023

Well, it doesn't help much. The error you see may indicate that zip file that are extracting is corrupt which may be caused by internet connection issues during download just before. Did you try to re-run build? Do you get this error always or it was just a single occasion?

@retirem
Copy link
Author

retirem commented Jun 12, 2023

Hmm, I understand. It was a single occasion, I did not try a re-run, because it is not a release-marked tag. In pipelines it is more complex to do a rerun anyway.

@vpolikarpov-akvelon
Copy link
Contributor

Chocolatey is installed using official script: https://chocolatey.org/install.ps1

It downloads chocolatey.zip archive using Request-File cmdlet and then extracts it. Seems like it neither stops on error nor have logic to retry download. I don't think it's a good idea to build workaround in this repo because your problem is quite unique and rare. If it persists, I think it would be better to address your request to Chocolatey team.

Сonsidering the above I'm closing this issue. Feel free to reach out if you have more questions.

@gep13
Copy link

gep13 commented Jun 13, 2023

@vpolikarpov-akvelon isn't Chocolatey CLI already installed on the runner image? If so, why the need to attempt to install it again?

@vpolikarpov-akvelon
Copy link
Contributor

Hey @gep13. You are right, Chocolatey is installed on runners hosted by GitHub. But this thread is about building your own runner from scratch.

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

No branches or pull requests

4 participants