diff --git a/src/setup-python.ts b/src/setup-python.ts index 3252213f0..69d8125bf 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -61,15 +61,21 @@ function resolveVersionInput(): string { } async function run() { - // When setting AGENT_TOOLSDIRECTORY, the actions/tool-cache function find - // is not able to find the files cached by actions/python-version. - if (process.env.AGENT_TOOLSDIRECTORY?.trim() && !IS_MAC) { + if (!process.env.AGENT_TOOLSDIRECTORY?.trim() && IS_MAC) { + process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache'; + } + + if (process.env.AGENT_TOOLSDIRECTORY?.trim()){ process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY']; - } else if (process.env.AGENT_TOOLSDIRECTORY?.trim() && IS_MAC) { - process.env['AGENT_TOOLSDIRECTORY'] = process.env['RUNNER_TOOL_CACHE']; - core.warning( - 'AGENT_TOOLSDIRECTORY is not valid for MacOS as shared libraries are configured with a fixed path.' - ); + } + + core.debug( + `Python is expected to be installed into ${ + process.env.AGENT_TOOLSDIRECTORY?.trim() + ? process.env['AGENT_TOOLSDIRECTORY'] + : process.env['RUNNER_TOOL_CACHE'] + }` + ); } core.debug( `Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`