Skip to content

Commit 9866d47

Browse files
Compiler: redirect DOTNET_INSTALL_DIR and GOPATH for ARC/DinD topology (#42855)
* fix: redirect DOTNET_INSTALL_DIR and GOPATH for ARC/DinD topology On ARC/DinD runners, setup-dotnet installs to /usr/share/dotnet by default which requires root permissions. Similarly, GOPATH defaults to a path that may not be writable or visible to the DinD daemon. Extend the existing 'Redirect tool cache for ARC/DinD' step to also set: - DOTNET_INSTALL_DIR -> ${RUNNER_TEMP}/gh-aw/tool-cache/dotnet - GOPATH -> ${RUNNER_TEMP}/gh-aw/tool-cache/go This ensures all runtime setup actions install to daemon-visible, writable paths. Fixes the 'mkdir: cannot create directory /usr/share/dotnet: Permission denied' error seen in ARC/DinD canary workflows. Related: #42807 * test: add assertions for DOTNET_INSTALL_DIR and GOPATH redirects --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 588de5c commit 9866d47

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

pkg/workflow/compiler_yaml_main_job.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,12 @@ func (c *Compiler) generateRuntimeAndWorkspaceSetupSteps(yaml *strings.Builder,
233233
// This step must run before any runtime setup steps (setup-go, setup-node, etc.) so that
234234
// those actions pick up the redirected path when they write into RUNNER_TOOL_CACHE.
235235
if isArcDindTopology(data) {
236-
yaml.WriteString(" - name: Redirect tool cache for ARC/DinD\n")
236+
yaml.WriteString(" - name: Redirect tool cache and install paths for ARC/DinD\n")
237237
yaml.WriteString(" run: |\n")
238238
yaml.WriteString(" mkdir -p \"${RUNNER_TEMP}/gh-aw/tool-cache\"\n")
239239
yaml.WriteString(" echo \"RUNNER_TOOL_CACHE=${RUNNER_TEMP}/gh-aw/tool-cache\" >> \"$GITHUB_ENV\"\n")
240+
yaml.WriteString(" echo \"DOTNET_INSTALL_DIR=${RUNNER_TEMP}/gh-aw/tool-cache/dotnet\" >> \"$GITHUB_ENV\"\n")
241+
yaml.WriteString(" echo \"GOPATH=${RUNNER_TEMP}/gh-aw/tool-cache/go\" >> \"$GITHUB_ENV\"\n")
240242
}
241243

242244
if needsCheckout || !customStepsContainCheckout {

pkg/workflow/compiler_yaml_main_job_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,9 +748,11 @@ func TestGenerateMainJobStepsArcDindRedirectsToolCacheToRunnerTemp(t *testing.T)
748748
require.NoError(t, err)
749749

750750
result := yaml.String()
751-
assert.Contains(t, result, "- name: Redirect tool cache for ARC/DinD")
751+
assert.Contains(t, result, "- name: Redirect tool cache and install paths for ARC/DinD")
752752
assert.Contains(t, result, `mkdir -p "${RUNNER_TEMP}/gh-aw/tool-cache"`)
753753
assert.Contains(t, result, `echo "RUNNER_TOOL_CACHE=${RUNNER_TEMP}/gh-aw/tool-cache" >> "$GITHUB_ENV"`)
754+
assert.Contains(t, result, `echo "DOTNET_INSTALL_DIR=${RUNNER_TEMP}/gh-aw/tool-cache/dotnet" >> "$GITHUB_ENV"`)
755+
assert.Contains(t, result, `echo "GOPATH=${RUNNER_TEMP}/gh-aw/tool-cache/go" >> "$GITHUB_ENV"`)
754756
assert.NotContains(t, result, "/tmp/gh-aw/tool-cache")
755757
}
756758

0 commit comments

Comments
 (0)