From 283bac3995d0cbdd2359ca2b449f63d33a9e7d0b Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Fri, 22 Oct 2021 14:24:31 +0300 Subject: [PATCH] Fix Ruby permissions (#4322) --- .../win/scripts/Installers/Install-Ruby.ps1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/Installers/Install-Ruby.ps1 b/images/win/scripts/Installers/Install-Ruby.ps1 index ef0436ae7..caf539500 100644 --- a/images/win/scripts/Installers/Install-Ruby.ps1 +++ b/images/win/scripts/Installers/Install-Ruby.ps1 @@ -43,10 +43,18 @@ function Install-Ruby [String]$Architecture = "x64" ) + # Create Ruby toolcache folder + $rubyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Ruby" + if (-not (Test-Path $rubyToolcachePath)) + { + Write-Host "Creating Ruby toolcache folder" + New-Item -ItemType Directory -Path $rubyToolcachePath | Out-Null + } + # Expand archive with binaries $packageName = [IO.Path]::GetFileNameWithoutExtension((Split-Path -Path $PackagePath -Leaf)) - $tempFolder = Join-Path -Path $env:TEMP -ChildPath $packageName - Extract-7Zip -Path $PackagePath -DestinationPath $env:TEMP + $tempFolder = Join-Path -Path $rubyToolcachePath -ChildPath $packageName + Extract-7Zip -Path $PackagePath -DestinationPath $rubyToolcachePath # Get Ruby version from binaries $rubyVersion = & "$tempFolder\bin\ruby.exe" -e "print RUBY_VERSION" @@ -54,16 +62,9 @@ function Install-Ruby if ($rubyVersion) { Write-Host "Installing Ruby $rubyVersion" - $rubyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Ruby" $rubyVersionPath = Join-Path -Path $rubyToolcachePath -ChildPath $rubyVersion $rubyArchPath = Join-Path -Path $rubyVersionPath -ChildPath $Architecture - if (-not (Test-Path $rubyToolcachePath)) - { - Write-Host "Creating Ruby toolcache folder" - New-Item -ItemType Directory -Path $rubyToolcachePath | Out-Null - } - Write-Host "Creating Ruby '${rubyVersion}' folder in '${rubyVersionPath}'" New-Item -ItemType Directory -Path $rubyVersionPath -Force | Out-Null