Skip to content

Commit 2b8eff3

Browse files
committed
fix: Self-Hosted Runner Tool Cache
This aligns the tool cache path logic with the process used by actions/python-versions, maintaining the ability to locate the version binaries, and fixing self-hosted runners. Fixes actions#459
1 parent c4e89fa commit 2b8eff3

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

‎dist/setup/index.js‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65278,14 +65278,11 @@ function resolveVersionInput() {
6527865278
function run() {
6527965279
var _a;
6528065280
return __awaiter(this, void 0, void 0, function* () {
65281-
// According to the README windows binaries do not require to be installed
65282-
// in the specific location, but Mac and Linux do
65283-
if (!utils_1.IS_WINDOWS && !((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) {
65284-
if (utils_1.IS_LINUX)
65285-
process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache';
65286-
else
65287-
process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
65288-
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
65281+
// This aligns us with actions/setup-python, which defaults their
65282+
// internal TOOLCACHE_ROOT to RUNNER_TOOL_CACHE when AGENT_TOOLSDIRECTORY
65283+
// is not set.
65284+
if (!((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) {
65285+
process.env['AGENT_TOOLSDIRECTORY'] = process.env['RUNNER_TOOL_CACHE'];
6528965286
}
6529065287
core.debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`);
6529165288
try {

‎src/setup-python.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55
import * as os from 'os';
66
import fs from 'fs';
77
import {getCacheDistributor} from './cache-distributions/cache-factory';
8-
import {isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS} from './utils';
8+
import {isCacheFeatureAvailable} from './utils';
99

1010
function isPyPyVersion(versionSpec: string) {
1111
return versionSpec.startsWith('pypy');
@@ -61,12 +61,11 @@ function resolveVersionInput(): string {
6161
}
6262

6363
async function run() {
64-
// According to the README windows binaries do not require to be installed
65-
// in the specific location, but Mac and Linux do
66-
if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) {
67-
if (IS_LINUX) process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache';
68-
else process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
69-
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
64+
// This aligns us with actions/setup-python, which defaults their
65+
// internal TOOLCACHE_ROOT to RUNNER_TOOL_CACHE when AGENT_TOOLSDIRECTORY
66+
// is not set.
67+
if (!process.env.AGENT_TOOLSDIRECTORY?.trim()) {
68+
process.env['AGENT_TOOLSDIRECTORY'] = process.env['RUNNER_TOOL_CACHE'];
7069
}
7170
core.debug(
7271
`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`

0 commit comments

Comments
 (0)