diff --git a/README.md b/README.md index 5c1859d..d7bd1f4 100644 --- a/README.md +++ b/README.md @@ -203,10 +203,10 @@ if the [virtual environment](https://github.com/actions/virtual-environments) is * Make sure to use the same operating system and version. * Make sure to use the same version of libssl. * Make sure that the operating system has `libyaml-0` installed -* The environment variable `RUNNER_TOOL_CACHE` must be set to same value as on GitHub-hosted runners - (`/opt/hostedtoolcache` on Linux, `/Users/runner/hostedtoolcache` on macOS, `C:\hostedtoolcache\windows` on Windows). -* That directory must be writable by the `runner` user. -* The runner software is running as user `runner` with a home directory of `/home/runner`, or you have created a symlink for the home directory of whatever user that the runner is running as to `/home/runner`. +* The default tool cache directory (`/opt/hostedtoolcache` on Linux, `/Users/runner/hostedtoolcache` on macOS, + `C:/hostedtoolcache/windows` on Windows) must be writable by the `runner` user. + This is necessary since the Ruby builds embed the install path when built and cannot be moved around. +* `/home/runner` must be writable by the `runner` user. In other cases, please use a system Ruby or [install Ruby manually](https://github.com/postmodern/chruby/wiki#installing-rubies) instead. diff --git a/common.js b/common.js index ec294dd..4334416 100644 --- a/common.js +++ b/common.js @@ -63,11 +63,21 @@ export function shouldExtractInToolCache(engine, version) { return engine === 'ruby' && !isHeadVersion(version) } -export function getToolCacheRubyPrefix(version) { - const toolCache = process.env['RUNNER_TOOL_CACHE'] - if (!toolCache) { - throw new Error('$RUNNER_TOOL_CACHE must be set') +function getPlatformToolCache(platform) { + // Hardcode paths rather than using $RUNNER_TOOL_CACHE because the prebuilt Rubies cannot be moved anyway + if (platform.startsWith('ubuntu-')) { + return '/opt/hostedtoolcache' + } else if (platform.startsWith('macos-')) { + return '/Users/runner/hostedtoolcache' + } else if (platform.startsWith('windows-')) { + return 'C:/hostedtoolcache/windows' + } else { + throw new Error('Unknown platform') } +} + +export function getToolCacheRubyPrefix(platform, version) { + const toolCache = getPlatformToolCache(platform) return path.join(toolCache, 'Ruby', version, 'x64') } diff --git a/dist/index.js b/dist/index.js index e57b3fa..5a4cf22 100644 --- a/dist/index.js +++ b/dist/index.js @@ -27714,7 +27714,7 @@ async function install(platform, engine, version) { let rubyPrefix if (common.shouldExtractInToolCache(engine, version)) { - rubyPrefix = common.getToolCacheRubyPrefix(version) + rubyPrefix = common.getToolCacheRubyPrefix(platform, version) } else { rubyPrefix = `${drive}:\\${base}` } @@ -32167,11 +32167,21 @@ function shouldExtractInToolCache(engine, version) { return engine === 'ruby' && !isHeadVersion(version) } -function getToolCacheRubyPrefix(version) { - const toolCache = process.env['RUNNER_TOOL_CACHE'] - if (!toolCache) { - throw new Error('$RUNNER_TOOL_CACHE must be set') +function getPlatformToolCache(platform) { + // Hardcode paths rather than using $RUNNER_TOOL_CACHE because the prebuilt Rubies cannot be moved anyway + if (platform.startsWith('ubuntu-')) { + return '/opt/hostedtoolcache' + } else if (platform.startsWith('macos-')) { + return '/Users/runner/hostedtoolcache' + } else if (platform.startsWith('windows-')) { + return 'C:/hostedtoolcache/windows' + } else { + throw new Error('Unknown platform') } +} + +function getToolCacheRubyPrefix(platform, version) { + const toolCache = getPlatformToolCache(platform) return path.join(toolCache, 'Ruby', version, 'x64') } @@ -52901,7 +52911,7 @@ async function install(platform, engine, version) { async function downloadAndExtract(platform, engine, version) { let rubyPrefix if (common.shouldExtractInToolCache(engine, version)) { - rubyPrefix = common.getToolCacheRubyPrefix(version) + rubyPrefix = common.getToolCacheRubyPrefix(platform, version) } else if (windows) { rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`) } else { diff --git a/ruby-builder.js b/ruby-builder.js index 1bb116c..cdbeb91 100644 --- a/ruby-builder.js +++ b/ruby-builder.js @@ -23,7 +23,7 @@ export async function install(platform, engine, version) { async function downloadAndExtract(platform, engine, version) { let rubyPrefix if (common.shouldExtractInToolCache(engine, version)) { - rubyPrefix = common.getToolCacheRubyPrefix(version) + rubyPrefix = common.getToolCacheRubyPrefix(platform, version) } else if (windows) { rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`) } else { diff --git a/windows.js b/windows.js index c5e3c49..89cc401 100644 --- a/windows.js +++ b/windows.js @@ -38,7 +38,7 @@ export async function install(platform, engine, version) { let rubyPrefix if (common.shouldExtractInToolCache(engine, version)) { - rubyPrefix = common.getToolCacheRubyPrefix(version) + rubyPrefix = common.getToolCacheRubyPrefix(platform, version) } else { rubyPrefix = `${drive}:\\${base}` }