G
YouTube TikTok Games
Skip to content

fix: respect pre-existing AGENT_TOOLSDIRECTORY on macOS self-hosted runners - #1387

Open
dahai80 wants to merge 1 commit into
actions:mainfrom
dahai80:fix/respect-agent-toolsdirectory-macos
Open

dahai80 wants to merge 1 commit into
actions:mainfrom
dahai80:fix/respect-agent-toolsdirectory-macos

Conversation

@dahai80

@dahai80 dahai80 commented Nov 13, 2026

Copy link
Copy Markdown

Summary

On macOS the action unconditionally overwrites AGENT_TOOLSDIRECTORY with the hosted-images default /Users/runner/hostedtoolcache:

src/setup-python.ts:

if (IS_MAC) {
  process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
}

Self-hosted macOS runners export their own AGENT_TOOLSDIRECTORY / RUNNER_TOOL_CACHE in the runner service environment. The hardcode discards both, so the downloaded setup.sh runs mkdir -p /Users/runner/hostedtoolcache and fails with mkdir: /Users/runner: Permission denied on hosts that have no runner user account.

Reproduction

Self-hosted macOS runner with RUNNER_TOOL_CACHE/AGENT_TOOLSDIRECTORY exported via the service wrapper (verified present in both bash and node step env), any actions/setup-python@v7 step that needs to download a Python version fails at the archive's install script:

Version 3.11 was not found in the local cache
Download from .../python-3.11.9-darwin-arm64.tar.gz
Execute installation script
Check if Python hostedtoolcache folder exist...
Creating Python hostedtoolcache folder...
##[error]mkdir: /Users/runner: Permission denied

Change

Fall back to /Users/runner/hostedtoolcache only when the runner did not provide a non-empty AGENT_TOOLSDIRECTORY. Behavior on GitHub-hosted macOS images is unchanged (they set AGENT_TOOLSDIRECTORY=/Users/runner/hostedtoolcache explicitly or the fallback applies identically).

Validation

  • Self-hosted macOS runner (Apple Silicon, macOS 26) with RUNNER_TOOL_CACHE/AGENT_TOOLSDIRECTORY pointing to a writable custom dir: previously every setup-python step failed with the mkdir error above; with the patched action logic the same step resolves the install dir from the runner-provided path.
  • Hosted macOS behavior: AGENT_TOOLSDIRECTORY is either pre-set by the image (unchanged) or the fallback applies (identical to current behavior).

Fixes #914 (macOS variant; the Linux /opt/hostedtoolcache symptom reported there has a separate code path)

🤖 Generated with Claude Code

…unners

On macOS the action unconditionally overwrites AGENT_TOOLSDIRECTORY with
the hosted-images default /Users/runner/hostedtoolcache. Self-hosted
macOS runners export their own AGENT_TOOLSDIRECTORY (and RUNNER_TOOL_CACHE)
in the runner service environment, but the hardcode discards both, so the
downloaded setup.sh attempts mkdir /Users/runner/hostedtoolcache and fails
with 'Permission denied' on hosts without a 'runner' user account.

Only fall back to the hosted default when the runner did not provide a
non-empty AGENT_TOOLSDIRECTORY.

Fixes actions#914 (macOS variant)

Co-Authored-By: Claude Code <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUNNER_TOOL_CACHE and/or AGENT_TOOLSDIRECTORY not picked up on self hosted runner

1 participant