Compare commits

...
7 Commits
Author SHA1 Message Date
Benoit Daloze 31a7f6d628 No longer remove the prefix before extraction, extracting should be idempotent
* Fixes https://github.com/ruby/setup-ruby/issues/191
2023-03-05 15:39:16 +01:00
Benoit Daloze 59b5745c73 Use tc.find() with the effective tool cache path
* So it finds already-download prebuilt Ruby in the GH-hosted tool cache path
  on self-hosted, where $RUNNER_TOOL_CACHE is often different than on GH-hosted.
* See #475.
* This relies on tc.find() looking up the env var every time:
  https://github.com/actions/toolkit/blob/1f4b3fac06/packages/tool-cache/src/tool-cache.ts#L522
2023-03-05 14:56:02 +01:00
Benoit Daloze d03a71de6e Fix tc.find() calls to use the proper name on self-hosted 2023-03-05 14:56:02 +01:00
Benoit Daloze ddde3938f5 Use the default tool cache path on self-hosted runners matching a GH-hosted runner image
* See https://github.com/ruby/setup-ruby/issues/475
* Semantically reverts 377a94bc68
2023-03-05 14:56:02 +01:00
Benoit Daloze 5a73aa9f67 Explain why it was detected as self-hosted 2023-03-03 18:01:46 +01:00
Benoit Daloze d01c52ad8b Add a self-hosted input to force considering the current runner as self-hosted
* Since checking for self-hosted is based on guessing as there is
  no proper predicate for it in GitHub Actions (AFAIK).
2023-03-03 18:01:46 +01:00
Benoit Daloze 377a94bc68 Consider a different $RUNNER_TOOL_CACHE than the default as a self-hosted runner
* Fixes https://github.com/ruby/setup-ruby/issues/242
2023-03-03 18:01:46 +01:00
6 changed files with 144 additions and 56 deletions
+5
View File
@@ -30,6 +30,11 @@ inputs:
description: | description: |
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
to invalidate the cache. to invalidate the cache.
self-hosted:
description: |
Consider the runner as a self-hosted runner, which means not using prebuilt Ruby binaries which only work
on GitHub-hosted runners or self-hosted runners with a very similar image to the ones used by GitHub runners.
The default is to detect this automatically based on the OS, OS version and $RUNNER_TOOL_CACHE.
outputs: outputs:
ruby-prefix: ruby-prefix:
description: 'The prefix of the installed ruby' description: 'The prefix of the installed ruby'
+60 -14
View File
@@ -5,6 +5,7 @@ const util = require('util')
const stream = require('stream') const stream = require('stream')
const crypto = require('crypto') const crypto = require('crypto')
const core = require('@actions/core') const core = require('@actions/core')
const tc = require('@actions/tool-cache')
const { performance } = require('perf_hooks') const { performance } = require('perf_hooks')
const linuxOSInfo = require('linux-os-info') const linuxOSInfo = require('linux-os-info')
import macosRelease from 'macos-release' import macosRelease from 'macos-release'
@@ -13,6 +14,10 @@ export const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14 // Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
export const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined) export const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
export const inputs = {
selfHosted: undefined
}
export function partition(string, separator) { export function partition(string, separator) {
const i = string.indexOf(separator) const i = string.indexOf(separator)
if (i === -1) { if (i === -1) {
@@ -162,9 +167,24 @@ const GitHubHostedPlatforms = [
'windows-2022-x64', 'windows-2022-x64',
] ]
// Actually a self-hosted runner which does not correspond to a GitHub-hosted runner image // Actually a self-hosted runner for which the OS and OS version does not correspond to a GitHub-hosted runner image,
export function isSelfHostedRunner() { export function isSelfHostedRunner() {
return !GitHubHostedPlatforms.includes(getOSNameVersionArch()) if (inputs.selfHosted === undefined) {
throw new Error('inputs.selfHosted should have been already set')
}
return inputs.selfHosted === 'true' ||
!GitHubHostedPlatforms.includes(getOSNameVersionArch())
}
export function selfHostedRunnerReason() {
if (inputs.selfHosted === 'true') {
return 'the self-hosted input was set'
} else if (!GitHubHostedPlatforms.includes(getOSNameVersionArch())) {
return 'the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported)'
} else {
return 'unknown reason'
}
} }
let virtualEnvironmentName = undefined let virtualEnvironmentName = undefined
@@ -213,35 +233,61 @@ export function shouldUseToolCache(engine, version) {
return (engine === 'ruby' && !isHeadVersion(version)) || isSelfHostedRunner() return (engine === 'ruby' && !isHeadVersion(version)) || isSelfHostedRunner()
} }
function getPlatformToolCache(platform) { export function getToolCachePath() {
if (isSelfHostedRunner()) { if (isSelfHostedRunner()) {
const runnerToolCache = process.env['RUNNER_TOOL_CACHE'] return getRunnerToolCache()
if (!runnerToolCache) { } else {
throw new Error('$RUNNER_TOOL_CACHE must be set on self-hosted runners') // Rubies prebuilt by this action embed this path rather than using $RUNNER_TOOL_CACHE
} // so use that path is not isSelfHostedRunner()
return runnerToolCache return getDefaultToolCachePath()
} }
// Hardcode paths rather than using $RUNNER_TOOL_CACHE because the prebuilt Rubies cannot be moved anyway }
export function getRunnerToolCache() {
const runnerToolCache = process.env['RUNNER_TOOL_CACHE']
if (!runnerToolCache) {
throw new Error('$RUNNER_TOOL_CACHE must be set')
}
return runnerToolCache
}
// Rubies prebuilt by this action embed this path rather than using $RUNNER_TOOL_CACHE
function getDefaultToolCachePath() {
const platform = getVirtualEnvironmentName()
if (platform.startsWith('ubuntu-')) { if (platform.startsWith('ubuntu-')) {
return '/opt/hostedtoolcache' return '/opt/hostedtoolcache'
} else if (platform.startsWith('macos-')) { } else if (platform.startsWith('macos-')) {
return '/Users/runner/hostedtoolcache' return '/Users/runner/hostedtoolcache'
} else if (platform.startsWith('windows-')) { } else if (platform.startsWith('windows-')) {
return 'C:/hostedtoolcache/windows' return 'C:\\hostedtoolcache\\windows'
} else { } else {
throw new Error('Unknown platform') throw new Error('Unknown platform')
} }
} }
export function getToolCacheRubyPrefix(platform, engine, version) { // tc.find() but using RUNNER_TOOL_CACHE=getToolCachePath()
const toolCache = getPlatformToolCache(platform) export function toolCacheFind(engine, version) {
const name = { const originalToolCache = getToolCachePath()
process.env['RUNNER_TOOL_CACHE'] = getToolCachePath()
try {
return tc.find(engineToToolCacheName(engine), version)
} finally {
process.env['RUNNER_TOOL_CACHE'] = originalToolCache
}
}
function engineToToolCacheName(engine) {
return {
ruby: 'Ruby', ruby: 'Ruby',
jruby: 'JRuby', jruby: 'JRuby',
truffleruby: 'TruffleRuby', truffleruby: 'TruffleRuby',
"truffleruby+graalvm": 'TruffleRubyGraalVM' "truffleruby+graalvm": 'TruffleRubyGraalVM'
}[engine] }[engine]
return path.join(toolCache, name, version, os.arch()) }
export function getToolCacheRubyPrefix(platform, engine, version) {
const toolCache = getToolCachePath()
return path.join(toolCache, engineToToolCacheName(engine), version, os.arch())
} }
export function toolCacheCompleteFile(toolCacheRubyPrefix) { export function toolCacheCompleteFile(toolCacheRubyPrefix) {
Generated Vendored
+72 -28
View File
@@ -291,10 +291,13 @@ __nccwpck_require__.d(__webpack_exports__, {
"drive": () => (/* binding */ drive), "drive": () => (/* binding */ drive),
"floatVersion": () => (/* binding */ floatVersion), "floatVersion": () => (/* binding */ floatVersion),
"getOSNameVersionArch": () => (/* binding */ getOSNameVersionArch), "getOSNameVersionArch": () => (/* binding */ getOSNameVersionArch),
"getRunnerToolCache": () => (/* binding */ getRunnerToolCache),
"getToolCachePath": () => (/* binding */ getToolCachePath),
"getToolCacheRubyPrefix": () => (/* binding */ getToolCacheRubyPrefix), "getToolCacheRubyPrefix": () => (/* binding */ getToolCacheRubyPrefix),
"getVirtualEnvironmentName": () => (/* binding */ getVirtualEnvironmentName), "getVirtualEnvironmentName": () => (/* binding */ getVirtualEnvironmentName),
"hasBundlerDefaultGem": () => (/* binding */ hasBundlerDefaultGem), "hasBundlerDefaultGem": () => (/* binding */ hasBundlerDefaultGem),
"hashFile": () => (/* binding */ hashFile), "hashFile": () => (/* binding */ hashFile),
"inputs": () => (/* binding */ inputs),
"isBundler1Default": () => (/* binding */ isBundler1Default), "isBundler1Default": () => (/* binding */ isBundler1Default),
"isBundler2Default": () => (/* binding */ isBundler2Default), "isBundler2Default": () => (/* binding */ isBundler2Default),
"isBundler2dot2Default": () => (/* binding */ isBundler2dot2Default), "isBundler2dot2Default": () => (/* binding */ isBundler2dot2Default),
@@ -303,11 +306,13 @@ __nccwpck_require__.d(__webpack_exports__, {
"isStableVersion": () => (/* binding */ isStableVersion), "isStableVersion": () => (/* binding */ isStableVersion),
"measure": () => (/* binding */ measure), "measure": () => (/* binding */ measure),
"partition": () => (/* binding */ partition), "partition": () => (/* binding */ partition),
"selfHostedRunnerReason": () => (/* binding */ selfHostedRunnerReason),
"setupPath": () => (/* binding */ setupPath), "setupPath": () => (/* binding */ setupPath),
"shouldUseToolCache": () => (/* binding */ shouldUseToolCache), "shouldUseToolCache": () => (/* binding */ shouldUseToolCache),
"targetRubyVersion": () => (/* binding */ targetRubyVersion), "targetRubyVersion": () => (/* binding */ targetRubyVersion),
"time": () => (/* binding */ time), "time": () => (/* binding */ time),
"toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile), "toolCacheCompleteFile": () => (/* binding */ toolCacheCompleteFile),
"toolCacheFind": () => (/* binding */ toolCacheFind),
"win2nix": () => (/* binding */ win2nix), "win2nix": () => (/* binding */ win2nix),
"windows": () => (/* binding */ windows) "windows": () => (/* binding */ windows)
}); });
@@ -357,6 +362,7 @@ const util = __nccwpck_require__(3837)
const stream = __nccwpck_require__(2781) const stream = __nccwpck_require__(2781)
const common_crypto = __nccwpck_require__(6113) const common_crypto = __nccwpck_require__(6113)
const core = __nccwpck_require__(2186) const core = __nccwpck_require__(2186)
const tc = __nccwpck_require__(7784)
const { performance } = __nccwpck_require__(4074) const { performance } = __nccwpck_require__(4074)
const linuxOSInfo = __nccwpck_require__(8487) const linuxOSInfo = __nccwpck_require__(8487)
; ;
@@ -365,6 +371,10 @@ const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14 // Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined) const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
const inputs = {
selfHosted: undefined
}
function partition(string, separator) { function partition(string, separator) {
const i = string.indexOf(separator) const i = string.indexOf(separator)
if (i === -1) { if (i === -1) {
@@ -514,9 +524,24 @@ const GitHubHostedPlatforms = [
'windows-2022-x64', 'windows-2022-x64',
] ]
// Actually a self-hosted runner which does not correspond to a GitHub-hosted runner image // Actually a self-hosted runner for which the OS and OS version does not correspond to a GitHub-hosted runner image,
function isSelfHostedRunner() { function isSelfHostedRunner() {
return !GitHubHostedPlatforms.includes(getOSNameVersionArch()) if (inputs.selfHosted === undefined) {
throw new Error('inputs.selfHosted should have been already set')
}
return inputs.selfHosted === 'true' ||
!GitHubHostedPlatforms.includes(getOSNameVersionArch())
}
function selfHostedRunnerReason() {
if (inputs.selfHosted === 'true') {
return 'the self-hosted input was set'
} else if (!GitHubHostedPlatforms.includes(getOSNameVersionArch())) {
return 'the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported)'
} else {
return 'unknown reason'
}
} }
let virtualEnvironmentName = undefined let virtualEnvironmentName = undefined
@@ -565,35 +590,61 @@ function shouldUseToolCache(engine, version) {
return (engine === 'ruby' && !isHeadVersion(version)) || isSelfHostedRunner() return (engine === 'ruby' && !isHeadVersion(version)) || isSelfHostedRunner()
} }
function getPlatformToolCache(platform) { function getToolCachePath() {
if (isSelfHostedRunner()) { if (isSelfHostedRunner()) {
const runnerToolCache = process.env['RUNNER_TOOL_CACHE'] return getRunnerToolCache()
if (!runnerToolCache) { } else {
throw new Error('$RUNNER_TOOL_CACHE must be set on self-hosted runners') // Rubies prebuilt by this action embed this path rather than using $RUNNER_TOOL_CACHE
} // so use that path is not isSelfHostedRunner()
return runnerToolCache return getDefaultToolCachePath()
} }
// Hardcode paths rather than using $RUNNER_TOOL_CACHE because the prebuilt Rubies cannot be moved anyway }
function getRunnerToolCache() {
const runnerToolCache = process.env['RUNNER_TOOL_CACHE']
if (!runnerToolCache) {
throw new Error('$RUNNER_TOOL_CACHE must be set')
}
return runnerToolCache
}
// Rubies prebuilt by this action embed this path rather than using $RUNNER_TOOL_CACHE
function getDefaultToolCachePath() {
const platform = getVirtualEnvironmentName()
if (platform.startsWith('ubuntu-')) { if (platform.startsWith('ubuntu-')) {
return '/opt/hostedtoolcache' return '/opt/hostedtoolcache'
} else if (platform.startsWith('macos-')) { } else if (platform.startsWith('macos-')) {
return '/Users/runner/hostedtoolcache' return '/Users/runner/hostedtoolcache'
} else if (platform.startsWith('windows-')) { } else if (platform.startsWith('windows-')) {
return 'C:/hostedtoolcache/windows' return 'C:\\hostedtoolcache\\windows'
} else { } else {
throw new Error('Unknown platform') throw new Error('Unknown platform')
} }
} }
function getToolCacheRubyPrefix(platform, engine, version) { // tc.find() but using RUNNER_TOOL_CACHE=getToolCachePath()
const toolCache = getPlatformToolCache(platform) function toolCacheFind(engine, version) {
const name = { const originalToolCache = getToolCachePath()
process.env['RUNNER_TOOL_CACHE'] = getToolCachePath()
try {
return tc.find(engineToToolCacheName(engine), version)
} finally {
process.env['RUNNER_TOOL_CACHE'] = originalToolCache
}
}
function engineToToolCacheName(engine) {
return {
ruby: 'Ruby', ruby: 'Ruby',
jruby: 'JRuby', jruby: 'JRuby',
truffleruby: 'TruffleRuby', truffleruby: 'TruffleRuby',
"truffleruby+graalvm": 'TruffleRubyGraalVM' "truffleruby+graalvm": 'TruffleRubyGraalVM'
}[engine] }[engine]
return path.join(toolCache, name, version, os.arch()) }
function getToolCacheRubyPrefix(platform, engine, version) {
const toolCache = getToolCachePath()
return path.join(toolCache, engineToToolCacheName(engine), version, os.arch())
} }
function toolCacheCompleteFile(toolCacheRubyPrefix) { function toolCacheCompleteFile(toolCacheRubyPrefix) {
@@ -68245,7 +68296,7 @@ function getAvailableVersions(platform, engine) {
async function install(platform, engine, version) { async function install(platform, engine, version) {
let rubyPrefix, inToolCache let rubyPrefix, inToolCache
if (common.shouldUseToolCache(engine, version)) { if (common.shouldUseToolCache(engine, version)) {
inToolCache = tc.find('Ruby', version) inToolCache = common.toolCacheFind(engine, version)
if (inToolCache) { if (inToolCache) {
rubyPrefix = inToolCache rubyPrefix = inToolCache
} else { } else {
@@ -68253,8 +68304,8 @@ async function install(platform, engine, version) {
if (common.isSelfHostedRunner()) { if (common.isSelfHostedRunner()) {
const rubyBuildDefinition = engine === 'ruby' ? version : `${engine}-${version}` const rubyBuildDefinition = engine === 'ruby' ? version : `${engine}-${version}`
core.error( core.error(
`The current runner (${common.getOSNameVersionArch()}) was detected as self-hosted and not matching a GitHub-hosted runner image.\n` + `The current runner (${common.getOSNameVersionArch()}) was detected as self-hosted because ${common.selfHostedRunnerReason()}.\n` +
`In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build:\n` + `In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build\n` +
`You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml\n` + `You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml\n` +
`$ ruby-build ${rubyBuildDefinition} ${toolCacheRubyPrefix}\n` + `$ ruby-build ${rubyBuildDefinition} ${toolCacheRubyPrefix}\n` +
`Once that completes successfully, mark it as complete with:\n` + `Once that completes successfully, mark it as complete with:\n` +
@@ -68275,7 +68326,7 @@ async function install(platform, engine, version) {
common.setupPath([path.join(rubyPrefix, 'bin')]) common.setupPath([path.join(rubyPrefix, 'bin')])
if (!inToolCache) { if (!inToolCache) {
await preparePrefix(rubyPrefix) await io.mkdirP(rubyPrefix)
if (engine === 'truffleruby+graalvm') { if (engine === 'truffleruby+graalvm') {
await installWithRubyBuild(engine, version, rubyPrefix) await installWithRubyBuild(engine, version, rubyPrefix)
} else { } else {
@@ -68286,15 +68337,6 @@ async function install(platform, engine, version) {
return rubyPrefix return rubyPrefix
} }
async function preparePrefix(rubyPrefix) {
const parentDir = path.dirname(rubyPrefix)
await io.rmRF(rubyPrefix)
if (!(fs.existsSync(parentDir) && fs.statSync(parentDir).isDirectory())) {
await io.mkdirP(parentDir)
}
}
async function installWithRubyBuild(engine, version, rubyPrefix) { async function installWithRubyBuild(engine, version, rubyPrefix) {
const tmp = process.env['RUNNER_TEMP'] || os.tmpdir() const tmp = process.env['RUNNER_TEMP'] || os.tmpdir()
const rubyBuildDir = path.join(tmp, 'ruby-build-for-setup-ruby') const rubyBuildDir = path.join(tmp, 'ruby-build-for-setup-ruby')
@@ -68459,7 +68501,7 @@ async function install(platform, engine, version) {
let rubyPrefix, inToolCache let rubyPrefix, inToolCache
if (common.shouldUseToolCache(engine, version)) { if (common.shouldUseToolCache(engine, version)) {
inToolCache = tc.find('Ruby', version) inToolCache = common.toolCacheFind(engine, version)
if (inToolCache) { if (inToolCache) {
rubyPrefix = inToolCache rubyPrefix = inToolCache
} else { } else {
@@ -69015,6 +69057,7 @@ const inputDefaults = {
'bundler-cache': 'false', 'bundler-cache': 'false',
'working-directory': '.', 'working-directory': '.',
'cache-version': bundler.DEFAULT_CACHE_VERSION, 'cache-version': bundler.DEFAULT_CACHE_VERSION,
'self-hosted': 'false',
} }
// entry point when this action is run on its own // entry point when this action is run on its own
@@ -69038,6 +69081,7 @@ async function setupRuby(options = {}) {
inputs[key] = core.getInput(key) || inputDefaults[key] inputs[key] = core.getInput(key) || inputDefaults[key]
} }
} }
common.inputs.selfHosted = inputs['self-hosted']
process.chdir(inputs['working-directory']) process.chdir(inputs['working-directory'])
+2
View File
@@ -16,6 +16,7 @@ const inputDefaults = {
'bundler-cache': 'false', 'bundler-cache': 'false',
'working-directory': '.', 'working-directory': '.',
'cache-version': bundler.DEFAULT_CACHE_VERSION, 'cache-version': bundler.DEFAULT_CACHE_VERSION,
'self-hosted': 'false',
} }
// entry point when this action is run on its own // entry point when this action is run on its own
@@ -39,6 +40,7 @@ export async function setupRuby(options = {}) {
inputs[key] = core.getInput(key) || inputDefaults[key] inputs[key] = core.getInput(key) || inputDefaults[key]
} }
} }
common.inputs.selfHosted = inputs['self-hosted']
process.chdir(inputs['working-directory']) process.chdir(inputs['working-directory'])
+4 -13
View File
@@ -20,7 +20,7 @@ export function getAvailableVersions(platform, engine) {
export async function install(platform, engine, version) { export async function install(platform, engine, version) {
let rubyPrefix, inToolCache let rubyPrefix, inToolCache
if (common.shouldUseToolCache(engine, version)) { if (common.shouldUseToolCache(engine, version)) {
inToolCache = tc.find('Ruby', version) inToolCache = common.toolCacheFind(engine, version)
if (inToolCache) { if (inToolCache) {
rubyPrefix = inToolCache rubyPrefix = inToolCache
} else { } else {
@@ -28,8 +28,8 @@ export async function install(platform, engine, version) {
if (common.isSelfHostedRunner()) { if (common.isSelfHostedRunner()) {
const rubyBuildDefinition = engine === 'ruby' ? version : `${engine}-${version}` const rubyBuildDefinition = engine === 'ruby' ? version : `${engine}-${version}`
core.error( core.error(
`The current runner (${common.getOSNameVersionArch()}) was detected as self-hosted and not matching a GitHub-hosted runner image.\n` + `The current runner (${common.getOSNameVersionArch()}) was detected as self-hosted because ${common.selfHostedRunnerReason()}.\n` +
`In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build:\n` + `In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build\n` +
`You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml\n` + `You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml\n` +
`$ ruby-build ${rubyBuildDefinition} ${toolCacheRubyPrefix}\n` + `$ ruby-build ${rubyBuildDefinition} ${toolCacheRubyPrefix}\n` +
`Once that completes successfully, mark it as complete with:\n` + `Once that completes successfully, mark it as complete with:\n` +
@@ -50,7 +50,7 @@ export async function install(platform, engine, version) {
common.setupPath([path.join(rubyPrefix, 'bin')]) common.setupPath([path.join(rubyPrefix, 'bin')])
if (!inToolCache) { if (!inToolCache) {
await preparePrefix(rubyPrefix) await io.mkdirP(rubyPrefix)
if (engine === 'truffleruby+graalvm') { if (engine === 'truffleruby+graalvm') {
await installWithRubyBuild(engine, version, rubyPrefix) await installWithRubyBuild(engine, version, rubyPrefix)
} else { } else {
@@ -61,15 +61,6 @@ export async function install(platform, engine, version) {
return rubyPrefix return rubyPrefix
} }
async function preparePrefix(rubyPrefix) {
const parentDir = path.dirname(rubyPrefix)
await io.rmRF(rubyPrefix)
if (!(fs.existsSync(parentDir) && fs.statSync(parentDir).isDirectory())) {
await io.mkdirP(parentDir)
}
}
async function installWithRubyBuild(engine, version, rubyPrefix) { async function installWithRubyBuild(engine, version, rubyPrefix) {
const tmp = process.env['RUNNER_TEMP'] || os.tmpdir() const tmp = process.env['RUNNER_TEMP'] || os.tmpdir()
const rubyBuildDir = path.join(tmp, 'ruby-build-for-setup-ruby') const rubyBuildDir = path.join(tmp, 'ruby-build-for-setup-ruby')
+1 -1
View File
@@ -49,7 +49,7 @@ export async function install(platform, engine, version) {
let rubyPrefix, inToolCache let rubyPrefix, inToolCache
if (common.shouldUseToolCache(engine, version)) { if (common.shouldUseToolCache(engine, version)) {
inToolCache = tc.find('Ruby', version) inToolCache = common.toolCacheFind(engine, version)
if (inToolCache) { if (inToolCache) {
rubyPrefix = inToolCache rubyPrefix = inToolCache
} else { } else {