Fix Windows container PATH being dropped after a $GITHUB_PATH write#10
Open
bugale wants to merge 1 commit into
Open
Fix Windows container PATH being dropped after a $GITHUB_PATH write#10bugale wants to merge 1 commit into
$GITHUB_PATH write#10bugale wants to merge 1 commit into
Conversation
On Windows, docker inspect .Config.Env rarely contains the container's PATH (servercore/nanoserver and most images don't declare it), so ParsePathFromConfigEnv returns empty. The later docker exec -e PATH= override then replaces the container PATH with only the prepended dirs -- System32 and PowerShell vanish and the next step's shell can't launch (hcs::CreateProcess 0x2, exit 126/127). PATH segments were also joined with a POSIX ':' separator. Read the container's real PATH at startup when .Config.Env has none, and join with Path.PathSeparator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9
Problem
On a Windows
container:job, after any step writes$GITHUB_PATH, every later in-container step fails to launch its shell:When a step appends to
$GITHUB_PATH,ContainerStepHost.ExecuteAsyncre-execs with an explicit overridedocker exec -e PATH="<prepend>:<ContainerRuntimePath>".ContainerRuntimePathis read once at container start fromdocker inspect .Config.Env(DockerUtil.ParsePathFromConfigEnv). On Windows that base is empty: typical Windows images (servercore, nanoserver, thedotnetimages) don't declarePathin.Config.Env— a Windows container's real PATH only exists at runtime. The override therefore drops System32/PowerShell, and the segments were joined with a POSIX:.Fix
ContainerOperationProvider: when.Config.Envhas no PATH on Windows, read the container's real PATH viadocker exec <id> cmd /c echo %PATH%.ContainerStepHost.ExecuteAsync: join withPath.PathSeparatorinstead of:.Testing
dotnet buildclean; existingDockerUtilL0,StepHostL0,ContainerOperationProviderL0tests pass (61).-e PATH="<prepend only>") fails withhcs::CreateProcess 0x2/ exit 127; with the container's live PATH appended and;separator the shell launches, the prepended dir stays first, and System32 is present (exit 0).Linux is unaffected:
Path.PathSeparatoris:there, and the live-PATH read is Windows-only and only triggers when.Config.Envhas no PATH.