Skip to content

Commit 9f1915a

Browse files
committed
fix: Self-Hosted Tool Cache
This fixes the tool cache path for self-hosted runners, along with handling AGENT_TOOLSDIRECTORY for both hosted + self-hosted. Fixes actions#459
1 parent 10b8409 commit 9f1915a

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

dist/setup/index.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -65340,13 +65340,9 @@ function resolveVersionInput() {
6534065340
function run() {
6534165341
var _a;
6534265342
return __awaiter(this, void 0, void 0, function* () {
65343-
// According to the README windows binaries do not require to be installed
65344-
// in the specific location, but Mac and Linux do
65345-
if (!utils_1.IS_WINDOWS && !((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim())) {
65346-
if (utils_1.IS_LINUX)
65347-
process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache';
65348-
else
65349-
process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
65343+
// When setting AGENT_TOOLSDIRECTORY, the actions/tool-cache function find
65344+
// is not able to find the files cached by actions/python-version.
65345+
if ((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim()) {
6535065346
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
6535165347
}
6535265348
core.debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`);

src/setup-python.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import fs from 'fs';
77
import {getCacheDistributor} from './cache-distributions/cache-factory';
88
import {
99
isCacheFeatureAvailable,
10-
logWarning,
11-
IS_LINUX,
12-
IS_WINDOWS
10+
logWarning
1311
} from './utils';
1412

1513
function isPyPyVersion(versionSpec: string) {
@@ -68,11 +66,9 @@ function resolveVersionInput(): string {
6866
}
6967

7068
async function run() {
71-
// According to the README windows binaries do not require to be installed
72-
// in the specific location, but Mac and Linux do
73-
if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) {
74-
if (IS_LINUX) process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache';
75-
else process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
69+
// When setting AGENT_TOOLSDIRECTORY, the actions/tool-cache function find
70+
// is not able to find the files cached by actions/python-version.
71+
if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
7672
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
7773
}
7874
core.debug(

0 commit comments

Comments
 (0)