Skip to content

fix: set AGENT_TOOLSDIRECTORY for self-hosted mode to prevent permission errors on macOS#6052

Open
xingzihai wants to merge 2 commits intonektos:masterfrom
xingzihai:fix-macos-runner-directory
Open

fix: set AGENT_TOOLSDIRECTORY for self-hosted mode to prevent permission errors on macOS#6052
xingzihai wants to merge 2 commits intonektos:masterfrom
xingzihai:fix-macos-runner-directory

Conversation

@xingzihai
Copy link
Copy Markdown

Summary

Fixes permission errors when using self-hosted mode on macOS with actions that rely on AGENT_TOOLSDIRECTORY (e.g., actions/setup-python).

Problem

When running act in self-hosted mode on macOS:

  1. The host system may have AGENT_TOOLSDIRECTORY set from a GitHub Actions runner installation (e.g., /Users/runner/hostedtoolcache)
  2. This environment variable is passed through to action scripts via os.Environ()
  3. Actions like setup-python check for AGENT_TOOLSDIRECTORY and use it if set
  4. The script tries to create /Users/runner/hostedtoolcache/Python, but:
    • /Users/runner doesn't exist
    • The user lacks permission to create it
    • The action fails with a permission error

Root Cause

In startHostEnvironment, the AGENT_TOOLSDIRECTORY from the host system's environment overrides the RUNNER_TOOL_CACHE value that act sets.

Solution

Explicitly set AGENT_TOOLSDIRECTORY to match RUNNER_TOOL_CACHE before the os.Environ() loop:

// Set AGENT_TOOLSDIRECTORY to match RUNNER_TOOL_CACHE for self-hosted mode
// This ensures that actions like setup-python use the correct tool cache path
// instead of potentially using a host system's AGENT_TOOLSDIRECTORY value
rc.Env["AGENT_TOOLSDIRECTORY"] = toolCache

This ensures:

  • AGENT_TOOLSDIRECTORY uses the act-defined path
  • Host system's AGENT_TOOLSDIRECTORY is ignored
  • Actions use the correct local cache path

Changes

  • pkg/runner/run_context.go (+4 lines)

Fixes #5974

Issue nektos#5971: Matrix multi-runner inconsistency

When using matrix strategy with multiple platforms (windows-latest, macos-latest,
ubuntu-latest), results were inconsistent. Sometimes all 3 runners were reported
as unsupported, even when ubuntu-latest was properly configured.

Root cause: EvaluateYamlNode modifies the yaml.Node in-place via ret.Decode(node).
Multiple matrix jobs running in parallel share the same Job object, so concurrent
calls to runsOnPlatformNames() raced to modify job.RawRunsOn, causing inconsistent
evaluation results.

Solution:
- Added EvaluateYamlNodeGetResult method to ExpressionEvaluator interface
  that returns the evaluated node without modifying the original
- Modified runsOnPlatformNames to use the new method
- Added helper functions extractRunsOnFromNode and nodeAsStringSlice
  to extract platform names from the returned evaluated node

This fix ensures each matrix job evaluates its own runs-on expression
without interfering with other parallel matrix jobs.
…ion errors on macOS

When running in self-hosted mode on macOS, actions like setup-python
may fail with 'mkdir: /Users/runner: Permission denied' because they
check AGENT_TOOLSDIRECTORY first before using RUNNER_TOOL_CACHE.

If AGENT_TOOLSDIRECTORY is set on the host system (e.g., from a previous
GitHub Actions runner installation), the Python setup script would use
that path instead of the act-defined RUNNER_TOOL_CACHE.

This fix sets AGENT_TOOLSDIRECTORY explicitly in self-hosted mode to
match RUNNER_TOOL_CACHE, ensuring that tool installation scripts use
the correct local tool cache path.

Fixes: nektos#5974
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

self-hosted on macOS is trying to create directory under /Users/runner

1 participant