actions / runner-images

GitHub Actions runner images
MIT License
9.17k stars 2.84k forks source link

Job fails on Ruby Installation task #4277

Closed jamelia1303 closed 2 years ago

jamelia1303 commented 2 years ago

Description

Hello! Is there any idea why it can happened ? I tried to build on different agents with different version and commits . thank you .

==> vhd: Provisioning with Powershell... ==> vhd: Provisioning with powershell script: D:\a\1\s\virtual-environments\images\win/scripts/Installers/Install-Ruby.ps1 vhd: Starting installation Ruby... vhd: Starting Ruby 2.4 installation vhd: Downloading package from: https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.10-1/rubyinstaller-2.4.10-1-x64.7z to path C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.4.10-1-x64.7z . vhd: Package downloaded successfully in 0.46 seconds vhd: Expand archive 'C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.4.10-1-x64.7z' to 'C:\Users\packer\AppData\Local\Temp' directory vhd: Installing Ruby 2.4.10 vhd: Creating Ruby toolcache folder vhd: Creating Ruby '2.4.10' folder in 'C:\hostedtoolcache\windows\Ruby\2.4.10' vhd: Moving Ruby '2.4.10' files to 'C:\hostedtoolcache\windows\Ruby\2.4.10\x64' ==> vhd: Move-Item : Access to the path 'C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.4.10-1-x64' is denied. ==> vhd: At C:\Windows\Temp\script-61678d15-2e79-037e-a8ff-6d41e5f5926b.ps1:71 char:9 ==> vhd: + Move-Item -Path $tempFolder -Destination $rubyArchPath | Out- ... ==> vhd: + ~~~~~~~~~~~~~~ ==> vhd: + CategoryInfo : WriteError: (C:\Users\packer...er-2.4.10-1-x64:DirectoryInfo) [Move-Item], IOException ==> vhd: + FullyQualifiedErrorId : MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand ==> vhd: ==> vhd: Provisioning step had errors: Running the cleanup provisioner, if present...

Virtual environments affected

Image version and build link

Current image version: '20211011.0'

Is it regression?

No response

Expected behavior

No response

Actual behavior

No response

Repro steps

Build image using main branch for win19

dibir-magomedsaygitov commented 2 years ago

Hello @jamelia1303. Thank you for your report. We will take a look.

DarkPitch commented 2 years ago

We have also been seeing this issue lately, most commonly on the ruby installation task, but also sometimes on the Install JavaTools part with a similar access denied error,

managedImage: Creating Java '11.0.12-7' folder in 'C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.12-7' managedImage: Expand archive 'C:\Users\packer\AppData\Local\Temp\OpenJDK11U-jdk_x64_windows_hotspot_11.0.12_7.zip' to 'C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.12-7' directory ==> managedImage: Rename-Item : Access to the path 'C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.12-7\jdk-11.0.12+7' is ==> managedImage: denied. ==> managedImage: At C:\Windows\Temp\script-61689aaf-c89c-ebba-00c2-c7b638d19329.ps1:95 char:44 ==> managedImage: + ... ChildItem -Path $javaVersionPath | Rename-Item -NewName $javaArchPath ==> managedImage: + ~~~~~~~~~~ ==> managedImage: + CategoryInfo : WriteError: (C:\hostedtoolca...7\jdk-11.0.12+7:String) [Rename-Item], IOException ==> managedImage: + FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand

jamelia1303 commented 2 years ago

We have also been seeing this issue lately, most commonly on the ruby installation task, but also sometimes on the Install JavaTools part with a similar access denied error,

managedImage: Creating Java '11.0.12-7' folder in 'C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.12-7' managedImage: Expand archive 'C:\Users\packer\AppData\Local\Temp\OpenJDK11U-jdk_x64_windows_hotspot_11.0.12_7.zip' to 'C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.12-7' directory ==> managedImage: Rename-Item : Access to the path 'C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.12-7\jdk-11.0.12+7' is ==> managedImage: denied. ==> managedImage: At C:\Windows\Temp\script-61689aaf-c89c-ebba-00c2-c7b638d19329.ps1:95 char:44 ==> managedImage: + ... ChildItem -Path $javaVersionPath | Rename-Item -NewName $javaArchPath ==> managedImage: + ~~~~~~~~~~ ==> managedImage: + CategoryInfo : WriteError: (C:\hostedtoolca...7\jdk-11.0.12+7:String) [Rename-Item], IOException ==> managedImage: + FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand

@DarkPitch Did you find any way how to fix it ? I tried to build the image using different commits and branches, from pipeline and from my local machine.. the same error ..

miketimofeev commented 2 years ago

Looks similar to this one https://github.com/actions/virtual-environments/issues/3588 and this https://github.com/actions/virtual-environments/issues/3228

jamelia1303 commented 2 years ago

@miketimofeev thank you! I applied that fix to Install-Ruby script . Tested locally and it worked. Now triggered pipeline to build an agent and hope it will succeeded ! just need to wait 3-4 hours ...

miketimofeev commented 2 years ago

@jamelia1303 thanks for the confirmation! If it helps we will have to change the scripts in the main as well.

jamelia1303 commented 2 years ago

@miketimofeev It helped with Ruby installation , but it failed with the same error on the next step. So I believe I need to do the same for other installation scripts. I'll go through them , change and test .

Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB) vhd: Installing collected packages: pip vhd: Attempting uninstall: pip vhd: Found existing installation: pip 20.0.2 vhd: Uninstalling pip-20.0.2: vhd: Successfully uninstalled pip-20.0.2 ==> vhd: WARNING: The scripts pip.exe, pip2.7.exe and pip2.exe are installed in 'C:\hostedtoolcache\windows\PyPy\2.7.18\x86\Scripts' which is not on PATH. ==> vhd: Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. vhd: Successfully installed pip-20.3.4 vhd: Create complete file vhd: Found PyPy 'pypy3.6-v7.3.3-win32.zip' package vhd: Downloading package from: https://downloads.python.org/pypy/pypy3.6-v7.3.3-win32.zip to path C:\Users\packer\AppData\Local\Temp\pypy3.6-v7.3.3-win32.zip . vhd: Package downloaded successfully in 0.27 seconds vhd: Expand archive 'C:\Users\packer\AppData\Local\Temp\pypy3.6-v7.3.3-win32.zip' to 'C:\Users\packer\AppData\Local\Temp' directory vhd: Put '7.3.3' to PYPY_VERSION file vhd: vhd: vhd: Directory: C:\Users\packer\AppData\Local\Temp\pypy3.6-v7.3.3-win32 vhd: vhd: vhd: Mode LastWriteTime Length Name vhd: ---- ------------- ------ ---- vhd: -a---- 10/15/2021 5:59 PM 5 PYPY_VERSION vhd: Installing PyPy 3.6.12 vhd: Create PyPy '3.6.12' folder in 'C:\hostedtoolcache\windows\PyPy\3.6.12' vhd: Move PyPy '3.6.12' files to 'C:\hostedtoolcache\windows\PyPy\3.6.12\x86' ==> vhd: Move-Item : Access to the path 'C:\Users\packer\AppData\Local\Temp\pypy3.6-v7.3.3-win32' is denied. ==> vhd: At C:\Windows\Temp\script-616996c4-78e2-c2c9-0ddb-0cace9f03aa7.ps1:59 char:9 ==> vhd: + Move-Item -Path $tempFolder -Destination $pypyArchPath | Out- ... ==> vhd: + ~~~~~~~~~~~~~~ ==> vhd: + CategoryInfo : WriteError: (C:\Users\packer....6-v7.3.3-win32:DirectoryInfo) [Move-Item], IOException ==> vhd: + FullyQualifiedErrorId : MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand ==> vhd: ==> vhd: Provisioning step had errors: Running the cleanup provisioner, if present...

miketimofeev commented 2 years ago

It looks like all the scripts that download archives to $env:TEMP are affected. We will investigate and try to fix the behavior.

mikhailkoliada commented 2 years ago

@jamelia1303 We have some questions:

  1. What is a vm size?
  2. What is a region you are building a vm for?
  3. What packer version are you using
  4. Have you modified the build templates?
  5. Could you modify the build scripts the way it shows your $env:TMP variable value and also permissions/owners of all the folders in the $env:TMP during build?
  6. Could you also modify a build scripts the way it shows the owner and permission for the C:\hostedtoolcache and all the folders in it?
jamelia1303 commented 2 years ago

@mikhailkoliada

  1. Standard D8s_v4
  2. East US 2 3.1.7.5
  3. no
  4. & 6. Sure , I modified scripts. I triggered the build , will post results in several hours
jamelia1303 commented 2 years ago

@mikhailkoliada I added logs :

mikhailkoliada commented 2 years ago

@jamelia1303 Thanks!

What I find curious is that your current logs show Java failure while original issue is about Ruby. I was unable to reproduce the Issue, I've made pretty simple changes to the repository: https://github.com/mikhailkoliada/virtual-environments/commit/ff711d8351afa9c63f45f38053f10da2324b8720

And the output can be found here in the logs https://github.visualstudio.com/08427f54-005b-4b34-b700-dca767ba7c14/_apis/build/builds/117970/logs/8

NateB2 commented 2 years ago

We've been running into the same issue when building the image - it seems to mostly fail either on the java step or the ruby step. We've also made no changes to the template and are using Packer 1.7.5. The errors look identical to the ones in the log @jamelia1303 posted.

miketimofeev commented 2 years ago

@NateB2 just to narrow it down — have you tried windows-2022? Does the issue persist there as well?

NateB2 commented 2 years ago

No, I have not (we're waiting for the necessary tooling we use to become compatible with VS 2022), but I will try today.

jamelia1303 commented 2 years ago

@miketimofeev yep... I see the difference comparing to my output ... 2021-10-19T15:49:02.5387860Z vhd: BUILTIN\Administrators Allow FullControl 2021-10-19T15:49:02.5388498Z vhd: pkrvmpqmkzvmc6s\packer Allow FullControl @NateB2 I tried self hosted / ms hosted agents 16/19....the same error. let me give it try using -windows-2022

miketimofeev commented 2 years ago

And just another shot in the dark — we have packer 1.7.2 on our image-generation agents (which is based on Windows-2016 azure image by the way). Can you give this version a try?

jamelia1303 commented 2 years ago

@miketimofeev sure , I'll try to build it with that version and win16 image. BTH: using windows-2022 did not make a difference...just the different error.

==> vhd: Waiting for machine to restart... ==> vhd: A system shutdown is in progress.(1115) vhd: pkrvmwey3vtxwbs restarted. ==> vhd: Machine successfully restarted, moving on ==> vhd: Provisioning with Powershell... ==> vhd: Provisioning with powershell script: D:\a\1\s\virtual-environments\images\win/scripts/Installers/Install-WindowsUpdates.ps1 vhd: . : The term 'c:/Windows/Temp/packer-ps-env-vars-616efe18-5ae8-5f20-866c-d16db48ce3a2.ps1' is not recognized as the vhd: name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was vhd: included, verify that the path is correct and try again. vhd: At line:1 char:138 vhd: + ... ontinue'};. c:/Windows/Temp/packer-ps-env-vars-616efe18-5ae8-5f20-866 ... vhd: + ~~~~~~~~~~~~~ vhd: + CategoryInfo : ObjectNotFound: (c:/Windows/Temp...16db48ce3a2.ps1:String) [], ParentContainsErrorRecord vhd: Exception vhd: + FullyQualifiedErrorId : CommandNotFoundException vhd:

timofla commented 2 years ago

I've experienced the same issue.

Either it fails on: ==> vhd: Rename-Item : Access to the path 'C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.302-8\jdk8u302-b08' is ==> vhd: denied.

or: Moving Ruby '2.6.8' folder to 'C:\hostedtollcache\windows\Ruby\2.6.8\x64'


packer version 1.7.6

NateB2 commented 2 years ago

@miketimofeev Nope, still same error on 2022 for us:

vhd: Creating Ruby toolcache folder
vhd: Creating Ruby '2.7.4' folder in 'C:\hostedtoolcache\windows\Ruby\2.7.4'
vhd: Moving Ruby '2.7.4' files to 'C:\hostedtoolcache\windows\Ruby\2.7.4\x64'
==> vhd: Move-Item : Access to the path 'C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.7.4-1-x64' is denied.

I will try 2019 using packer 1.7.2.

timofla commented 2 years ago

Same issue with 2019, packer 1.7.2

==> vhd: Move-Item : Access to the path 'C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.5.9-1-x64' is denied. vhd: Creating Ruby '2.5.9' folder in 'C:\hostedtoolcache\windows\Ruby\2.5.9' vhd: Moving Ruby '2.5.9' files to 'C:\hostedtoolcache\windows\Ruby\2.5.9\x64' ==> vhd: At C:\Windows\Temp\script-616f0ffd-439f-0158-8873-1c21467f73ee.ps1:71 char:9 ==> vhd: + Move-Item -Path $tempFolder -Destination $rubyArchPath | Out- ... ==> vhd: + ~~~~~~~~~~~~~~ ==> vhd: + CategoryInfo : WriteError: (C:\Users\packer...ler-2.5.9-1-x64:DirectoryInfo) [Move-Item], IOException ==> vhd: + FullyQualifiedErrorId : MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand ==> vhd: ==> vhd: Script exited with non-zero exit status: 1.Allowed exit codes are: [0] ==> vhd: Step "StepProvision" failed

NateB2 commented 2 years ago

@miketimofeev - Switching to 1.7.2 on 2019 worked for us, but it could have been a fluke, judging by @timofla 's experience?

I'm out of town the next few days, but if it's not resolved by Monday, I'll try it again to see if it will fail on a re-run.

dgcaron commented 2 years ago

@jamelia1303 could you share what you changed because i am running into the same issue and i am not quite sure what to alter?

mikhailkoliada commented 2 years ago

@jamelia1303 could you please share a full build log (not just the part with the error) and could you please also provide the packer command you are using to build an image?

jamelia1303 commented 2 years ago

@mikhailkoliada

I use just basic command ... packer build -var "capture_name_prefix=$ResourcesNamePrefix" -var "client_id=$ClientId" -var "client_secret=$ClientSecret" -var "install_password=$InstallPassword" -var "github_feed_token=$GitHubFeedToken" -var "location=$Location" -var "resource_group=$ResourceGroup" -var "storage_account=$StorageAccount" -var "subscription_id=$SubscriptionId" -var "temp_resource_group_name=$TempResourceGroupName" -var "tenant_id=$TenantId" $TemplatePath

Switching to 1.7.2 did not help...

miketimofeev commented 2 years ago

@jamelia1303 could you try using not the MS hosted agent to build an image but either self-hosted windows agent or even your local dev-box?

miketimofeev commented 2 years ago

@jamelia1303 and one more thing to try as we suspect that there is something wrong with $env:TEMP — could you change these lines https://github.com/actions/virtual-environments/blob/335de740856f0a7c8c003d4908e491dadfb33cff/images/win/scripts/ImageHelpers/InstallHelpers.ps1#L169-L184 to

function Start-DownloadWithRetry
{
    Param
    (
        [Parameter(Mandatory)]
        [string] $Url,
        [string] $Name,
        [string] $DownloadPath = "C:\Temp",
        [int] $Retries = 20
    )

    if ([String]::IsNullOrEmpty($Name)) {
        $Name = [IO.Path]::GetFileName($Url)
    }

    if (-not (Test-Path -Path $DownloadPath))
    {
        New-Item -Path $DownloadPath -ItemType Directory -Force | Out-Null
    }

    $filePath = Join-Path -Path $DownloadPath -ChildPath $Name

and run the builds.

jamelia1303 commented 2 years ago

function Start-DownloadWithRetry { Param ( [Parameter(Mandatory)] [string] $Url, [string] $Name, [string] $DownloadPath = "C:\Temp", [int] $Retries = 20 )

if ([String]::IsNullOrEmpty($Name)) {
    $Name = [IO.Path]::GetFileName($Url)
}

if (-not (Test-Path -Path $DownloadPath))
{
    New-Item -Path $DownloadPath -ItemType Directory -Force
}

$filePath = Join-Path -Path $DownloadPath -ChildPath $Name

sure. let me try to build it with those changes locally and using 1.7.2 version. I

rink72 commented 2 years ago

@miketimofeev @jamelia1303 we are also having this exact issue. I have just kicked off a build with the updated function above and will let you know how it goes. Also testing with packer 1.7.2

miketimofeev commented 2 years ago

@rink72 do you also use hosted agents to build the image?

rink72 commented 2 years ago

@miketimofeev yeah, we've been using windows-latest but plan to change to our own private agents once we have this building correctly. The only reason we're not at the moment is they don't have packer on them by default.

miketimofeev commented 2 years ago

@rink72 we have never actually tried to build the images using hosted agent due to various reasons and probably that's why we haven't faced the issue.

rink72 commented 2 years ago

@miketimofeev are the agents you use based on the virtual-environments builds or are they custom?

miketimofeev commented 2 years ago

@rink72 they are custom but it's just clean windows-2016 azure image with packer and azure-cli installed

davidjward30 commented 2 years ago

Same issue here. I have been building windows-2019 from tags for over a year without this issue. 20210916.1 was the last tag to build fine for me but 20211019.1 just wont build with similar issue to those described above. I tried upgrading packer to the latest version but it didn't make any difference.

al-cheb commented 2 years ago

Same issue here. I have been building windows-2019 from tags for over a year without this issue. 20210916.1 was the last tag to build fine for me but 20211019.1 just wont build with similar issue to those described above. I tried upgrading packer to the latest version but it didn't make any difference.

You have to use only main branch to build images, because we don't backport any changes to tags.

al-cheb commented 2 years ago

@timofla, @jamelia1303, @hbuckle: I have created a debug build with minimal steps to repro. Could you please attach logs for Windows Server 2019?

https://github.com/al-cheb/virtual-environments/tree/test-build
repo: https://github.com/al-cheb/virtual-environments
branch: test-build
jamelia1303 commented 2 years ago

@al-cheb Sure. I built it using you repo and test-build branch for Win-19. Agent: MS hosted Windows Latest Packer 1.7.2

jamelia1303 commented 2 years ago

@miketimofeev I made those changes and it failed on the different step

..

miketimofeev commented 2 years ago

@jamelia1303 sorry, there was an error in my snippet, I forgot to add Out-Nullto the directory creation. Should be New-Item -Path $DownloadPath -ItemType Directory -Force | Out-Null

al-cheb commented 2 years ago

@al-cheb Sure. I built it using you repo and test-build branch for Win-19. Agent: MS hosted Windows Latest Packer 1.7.2 debuglog.txt

Thank you. I did not see any issues related to Access Denied. What branch did you use previously for full build?

jamelia1303 commented 2 years ago

@al-cheb I used main branch. I also tried to use 20211011 but got the same result.

jamelia1303 commented 2 years ago

@jamelia1303 sorry, there was an error in my snippet, I forgot to add Out-Nullto the directory creation. Should be New-Item -Path $DownloadPath -ItemType Directory -Force | Out-Null

Hm...got the new error... What branch should I use to apply those changes ?

vhd: Running tests from 'C:\image\Tests\WDK.Tests.ps1'
vhd: Describing WDK
vhd:   [+] WDK exists 52.05s (51.85s|194ms)
vhd:   [+] WDK version from system 140ms (59ms|81ms)
vhd: Tests completed in 55.23s
vhd: Tests Passed: 2, Failed: 0, Skipped: 0 NotRun: 0

==> vhd: Provisioning with powershell script: D:\a\1\s\virtual-environments\images\win/scripts/Installers/Install-Vsix.ps1 vhd: Downloading package from: https://probitools.gallerycdn.vsassets.io/extensions/probitools/microsoftanalysisservicesmodelingprojects/2.9.18/1626109082514/Microsoft.DataTools.AnalysisServices.vsix to path C:\Temp\Microsoft.DataTools.AnalysisServices.vsix . vhd: Package downloaded successfully in 1.42 seconds vhd: Starting Install Microsoft.DataTools.AnalysisServices.vsix... vhd: Microsoft.DataTools.AnalysisServices.vsix installed successfully vhd: Downloading package from: https://ssis.gallerycdn.vsassets.io/extensions/ssis/sqlserverintegrationservicesprojects/3.15/1629091547410/Microsoft.DataTools.IntegrationServices.exe to path C:\Temp\Microsoft.DataTools.IntegrationServices.exe . vhd: Package downloaded successfully in 1.58 seconds vhd: Starting Install Microsoft.DataTools.IntegrationServices.exe... vhd: There is an error during Microsoft.DataTools.IntegrationServices.exe installation vhd: Start-Process : This command cannot be run due to the error: The system cannot find the file specified. vhd: At C:\Program Files\WindowsPowerShell\Modules\ImageHelpers\InstallHelpers.ps1:285 char:24 vhd: + ... $process = Start-Process -FilePath ${env:Temp}\$Name /Q -Wait -PassT ... vhd: + ~~~~~~~~~~~~~ vhd: + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException vhd: + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand vhd: ==> vhd: Provisioning step had errors: Running the cleanup provisioner, if present...

miketimofeev commented 2 years ago

@jamelia1303 I missed one more place where $env:Temp is used 🤷 Fixed (I hope because didn't have a chance to test) in this branch https://github.com/miketimofeev/virtual-environments/tree/windows-test-another-download-path

rink72 commented 2 years ago

@miketimofeev @al-cheb, I just tried using C:\temp (I had to make a few more changes as $env:TEMP was used in a couple more places but still running in to the same error when getting to the ruby installers but now with access denied in C:\Temp. So it doesn't appear to be an issue with just $env:TEMP? Maybe it's something with the 7z extraction?

My branch for reference: https://github.com/rink72/virtual-environments/tree/working/temp-testing

I've attached the log from the build job in case it's of any use.

build-log.txt

jamelia1303 commented 2 years ago

@jamelia1303 I missed one more place where $env:Temp is used 🤷 Fixed (I hope because didn't have a chance to test) in this branch https://github.com/miketimofeev/virtual-environments/tree/windows-test-another-download-path

I faced that issue again. I believe I need to reapply previous fix to Ruby installation. I'll do it a bit later and will post the result.

2021-10-21T21:53:51.7383273Z vhd: Starting Ruby 2.6 installation 2021-10-21T21:53:51.7395819Z vhd: Downloading package from: https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.8-1/rubyinstaller-2.6.8-1-x64.7z to path C:\Temp\rubyinstaller-2.6.8-1-x64.7z . 2021-10-21T21:53:52.9716482Z vhd: Package downloaded successfully in 1.22 seconds 2021-10-21T21:53:52.9724114Z vhd: Expand archive 'C:\Temp\rubyinstaller-2.6.8-1-x64.7z' to 'C:\Users\packer\AppData\Local\Temp' directory 2021-10-21T21:54:23.4024141Z vhd: Installing Ruby 2.6.8 2021-10-21T21:54:23.4030548Z vhd: Creating Ruby '2.6.8' folder in 'C:\hostedtoolcache\windows\Ruby\2.6.8' 2021-10-21T21:54:26.0464510Z vhd: Moving Ruby '2.6.8' files to 'C:\hostedtoolcache\windows\Ruby\2.6.8\x64' 2021-10-21T21:54:26.0471546Z ==> vhd: Move-Item : Access to the path 'C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.6.8-1-x64' is denied. 2021-10-21T21:54:26.0482234Z ==> vhd: At C:\Windows\Temp\script-6171b5fe-f5f7-45cb-8b22-bbc3c06c9f77.ps1:71 char:9 2021-10-21T21:54:26.0496367Z ==> vhd: + Move-Item -Path $tempFolder -Destination $rubyArchPath | Out- ... 2021-10-21T21:54:26.0505406Z ==> vhd: + ~~~~~~~~~~~~~~

andersosthus commented 2 years ago

I've applied all the fixes in the branch @miketimofeev referenced above, and that has fixed the issue with Ruby for me, but I'm still getting intermittent issues with Java installs:


    vhd: Downloading package from: https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08.1/OpenJDK8U-jdk_x64_windows_hotspot_8u302b08.zip to path C:\Temp\OpenJDK8U-jdk_x64_windows_hotspot_8u302b08.zip .
    vhd: Package downloaded successfully in 0.53 seconds
    vhd: Creating Adopt toolcache folder
    vhd: Creating Java '8.0.302-8' folder in 'C:\hostedtoolcache\windows\Java_Adopt_jdk\8.0.302-8'
    vhd: Expand archive 'C:\Temp\OpenJDK8U-jdk_x64_windows_hotspot_8u302b08.zip' to 'C:\hostedtoolcache\windows\Java_Adopt_jdk\8.0.302-8' directory
==> vhd: Rename-Item : Access to the path 'C:\hostedtoolcache\windows\Java_Adopt_jdk\8.0.302-8\jdk8u302-b08' is denied.
al-cheb commented 2 years ago

@andersosthus , Could you please replace the function Install-JavaJDK in the script Install-JavaTools.ps1 and attach logs?

Install-JavaJDK

``` function Install-JavaJDK { param( [string] $JDKVersion, [string] $Architecture = "x64", [string] $VendorName ) # Get Java version from api if ($VendorName -eq "Temurin-Hotspot") { $assetUrl = Invoke-RestMethod -Uri "https://api.adoptium.net/v3/assets/latest/${JDKVersion}/hotspot" } elseif ($VendorName -eq "Adopt") { $assetUrl = Invoke-RestMethod -Uri "https://api.adoptopenjdk.net/v3/assets/latest/${JDKVersion}/hotspot" } else { throw "$VendorName is invalid vendor name. 'Adopt' and 'Temurin-Hotspot' are allowed values" } $asset = $assetUrl | Where-Object { $_.binary.os -eq "windows" ` -and $_.binary.architecture -eq $Architecture ` -and $_.binary.image_type -eq "jdk" } # Download and extract java binaries to temporary folder $downloadUrl = $asset.binary.package.link $archivePath = Start-DownloadWithRetry -Url $downloadUrl -Name $([IO.Path]::GetFileName($downloadUrl)) 1 > $env:TEMP\123.txt Write-Host (Get-ChildItem $env:TEMP -Force | Out-String) # We have to replace '+' sign in the version to '-' due to the issue with incorrect path in Android builds https://github.com/actions/virtual-environments/issues/3014 $fullJavaVersion = $asset.version.semver -replace '\+', '-' # Create directories in toolcache path $javaToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Java_${VendorName}_jdk" $javaVersionPath = Join-Path -Path $javaToolcachePath -ChildPath $fullJavaVersion $javaArchPath = Join-Path -Path $javaVersionPath -ChildPath $Architecture if (-not (Test-Path $javaToolcachePath)) { Write-Host "Creating ${VendorName} toolcache folder" New-Item -ItemType Directory -Path $javaToolcachePath | Out-Null } Write-Host "Creating Java '${fullJavaVersion}' folder in '${javaVersionPath}'" New-Item -ItemType Directory -Path $javaVersionPath -Force | Out-Null # Complete the installation by extarcting Java binaries to toolcache and creating the complete file Extract-7Zip -Path $archivePath -DestinationPath $javaVersionPath try { Write-Host "Rename '$javaVersionPath' to '$javaArchPath' path" Write-Host (Get-ChildItem -Path $javaVersionPath | Out-String) Get-ChildItem -Path $javaVersionPath | Rename-Item -NewName $javaArchPath -Verbose -ErrorAction Stop } catch { Get-CimInstance Win32_Process | ? CommandLine | Sort Name | Format-List Name,CommandLine Invoke-WebRequest https://live.sysinternals.com/handle64.exe -OutFile handle64.exe & .\handle64.exe -nobanner -accepteula } New-Item -ItemType File -Path $javaVersionPath -Name "$Architecture.complete" | Out-Null } ```

andersosthus commented 2 years ago

@al-cheb I'll try the updated script after the current build completes.

dgcaron commented 2 years ago

@al-cheb changed the Install-JavaJDK and ran the build from my local box the java install worked but I forgot I discarded the changes on the ruby installer. re-running now with both changes

update: ruby still fails for me

==> vhd: Provisioning with Powershell...
==> vhd: Provisioning with powershell script: C:\Users\DidierCaron\source\repos\devops\virtual-environments\images\win/scripts/Installers/Install-Ruby.ps1
    vhd: Starting installation Ruby...
    vhd: Starting Ruby 2.4 installation
    vhd: Downloading package from: https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.10-1/rubyinstaller-2.4.10-1-x64.7z to path C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.4.10-1-x64.7z .
    vhd: Package downloaded successfully in 0.94 seconds
    vhd: Creating Ruby toolcache folder
    vhd: Expand archive 'C:\Users\packer\AppData\Local\Temp\rubyinstaller-2.4.10-1-x64.7z' to 'C:\hostedtoolcache\windows\Ruby' directory
    vhd: Installing Ruby 2.4.10
    vhd: Creating Ruby '2.4.10' folder in 'C:\hostedtoolcache\windows\Ruby\2.4.10'
    vhd: Moving Ruby '2.4.10' files to 'C:\hostedtoolcache\windows\Ruby\2.4.10\x64'
==> vhd: Move-Item : Access to the path 'C:\hostedtoolcache\windows\Ruby\rubyinstaller-2.4.10-1-x64' is denied.
==> vhd: At C:\Windows\Temp\script-61729dee-29f1-f2f6-a61c-8f21924d95d2.ps1:72 char:9
==> vhd: +         Move-Item -Path $tempFolder -Destination $rubyArchPath | Out- ...
==> vhd: +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==> vhd:     + CategoryInfo          : WriteError: (C:\hostedtoolca...er-2.4.10-1-x64:DirectoryInfo) [Move-Item], IOException
==> vhd:     + FullyQualifiedErrorId : MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
==> vhd:
==> vhd: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]
==> vhd: Step "StepProvision" failed