8000 Use a hardcoded toolcache path since we need to extract there to let … · ruby/setup-ruby@ba761ba · GitHub
[go: up one dir, main page]

Skip to content

Commit ba761ba

Browse files
committed
Use a hardcoded toolcache path since we need to extract there to let Ruby work
1 parent bb3a0c6 commit ba761ba

File tree

5 files changed

+36
-16
lines changed

5 files changed

+36
-16
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ if the [virtual environment](https://github.com/actions/virtual-environments) is
203203
* Make sure to use the same operating system and version.
204204
* Make sure to use the same version of libssl.
205205
* Make sure that the operating system has `libyaml-0` installed
206-
* The environment variable `RUNNER_TOOL_CACHE` must be set to same value as on GitHub-hosted runners
207-
(`/opt/hostedtoolcache` on Linux, `/Users/runner/hostedtoolcache` on macOS, `C:\hostedtoolcache\windows` on Windows).
208-
* That directory must be writable by the `runner` user.
209-
* 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`.
206+
* The default tool cache directory (`/opt/hostedtoolcache` on Linux, `/Users/runner/hostedtoolcache` on macOS,
207+
`C:/hostedtoolcache/windows` on Windows) must be writable by the `runner` user.
208+
This is necessary since the Ruby builds embed the install path when built and cannot be moved around.
209+
* `/home/runner` must be writable by the `runner` user.
210210

211211
In other cases, please use a system Ruby or [install Ruby manually](https://github.com/postmodern/chruby/wiki#installing-rubies) instead.
212212

common.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,21 @@ export function shouldExtractInToolCache(engine, version) {
6363
return engine === 'ruby' && !isHeadVersion(version)
6464
}
6565

66-
export function getToolCacheRubyPrefix(version) {
67-
const toolCache = process.env['RUNNER_TOOL_CACHE']
68-
if (!toolCache) {
69-
throw new Error('$RUNNER_TOOL_CACHE must be set')
66+
function getPlatformToolCache(platform) {
67+
// Hardcode paths rather than using $RUNNER_TOOL_CACHE because the prebuilt Rubies cannot be moved anyway
68+
if (platform.startsWith('ubuntu-')) {
69+
return '/opt/hostedtoolcache'
70+
} else if (platform.startsWith('macos-')) {
71+
return '/Users/runner/hostedtoolcache'
72+
} else if (platform.startsWith('windows-')) {
73+
return 'C:/hostedtoolcache/windows'
74+
} else {
75+
throw new Error('Unknown platform')
7076
}
77+
}
78+
79+
export function getToolCacheRubyPrefix(platform, version) {
80+
const toolCache = getPlatformToolCache(platform)
7181
return path.join(toolCache, 'Ruby', version, 'x64')
7282
}
7383

dist/index.js

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ruby-builder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function install(platform, engine, version) {
2323
async function downloadAndExtract(platform, engine, version) {
2424
let rubyPrefix
2525
if (common.shouldExtractInToolCache(engine, version)) {
26-
rubyPrefix = common.getToolCacheRubyPrefix(version)
26+
rubyPrefix = common.getToolCacheRubyPrefix(platform, version)
2727
} else if (windows) {
2828
rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`)
2929
} else {

windows.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function install(platform, engine, version) {
3838

3939
let rubyPrefix
4040
if (common.shouldExtractInToolCache(engine, version)) {
41-
rubyPrefix = common.getToolCacheRubyPrefix(version)
41+
rubyPrefix = common.getToolCacheRubyPrefix(platform, version)
4242
} else {
4343
rubyPrefix = `${drive}:\\${base}`
4444
}

0 commit comments

Comments
 (0)
0