Fix Ruby permissions (#4322)

This commit is contained in:
Aleksandr Chebotov
2021-10-22 14:24:31 +03:00
committed by GitHub
parent db36e4a622
commit 283bac3995

View File

@@ -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