Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Removed the default set PATH for Windows environments. #4895

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielGithinji
Copy link

@danielGithinji danielGithinji commented May 2, 2024

This change is related to this PR: Don't set a default PATH for Windows.

Description:

This change seeks to remove the defaulted Windows image path found in util\system\path.go.

I used buildkit to create two images with following docker file contents:

FROM mcr.microsoft.com/windows/servercore:ltsc2022

RUN echo %PATH%

CMD ["powershell", "-Command", "Write-Host", "$env:PATH"]

For one image the PATH in util\system\path.go is defaulted to "c:\Windows\System32;c:\Windows" while for the other image the PATH is defaulted to an empty string.

  • When you run the 1st image that contains the default path it gives the following result:
PS C:\Users\dgithinji> ctr run docker.io/gmanguru/fix-windows-path:withDefaultPath withDefaultPath
ctr: hcs::System::CreateProcess: powershell -Command Write-Host $env:PATH withDefaultPath: The system cannot find the file specified.: unknown
  • While the 2nd image that has no PATH set gives the following result:
PS C:\Users\dgithinji> ctr run docker.io/gmanguru/fix-windows-path:NoDefaultPath NoDefaultPath
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps

In mcr.microsoft.com/windows/servercore:ltsc2022, PowerShell is available in "C:\Windows\System32\WindowsPowerShell\v1.0". When the PATH is defaulted to a specific value, application files for applications like PowerShell cannot be found/referenced hence the need to remove the defaulted path.

@danielGithinji danielGithinji changed the title Removed the default set PATH for Windows environments to allow Window… Removed the default set PATH for Windows environments. May 2, 2024
@danielGithinji danielGithinji marked this pull request as draft May 2, 2024 08:07
@danielGithinji danielGithinji changed the title Removed the default set PATH for Windows environments. RFC: Removed the default set PATH for Windows environments. May 2, 2024
…s images to set the PATH while running

Signed-off-by: Daniel Githinji <dgithinji@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants