docs: stop copying machine PATH into user PATH in Windows CLI install - #1993
Open
jato-c8y wants to merge 1 commit into
Open
docs: stop copying machine PATH into user PATH in Windows CLI install#1993jato-c8y wants to merge 1 commit into
jato-c8y wants to merge 1 commit into
Conversation
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.
The snippet persisted $env:Path to the user scope. $env:Path is the machine and user PATH already merged, so every run copied the whole machine PATH into the user's PATH, and re-running grew it again. Those frozen copies then shadow later machine-PATH changes.
Read the user PATH from HKCU\Environment unexpanded instead, append the devpod directory, and write it back as REG_EXPAND_SZ so every other entry survives byte-for-byte. Skip the write when the entry is already present.
GetEnvironmentVariable('Path','User') is not a usable source: it expands %VAR% on read, and SetEnvironmentVariable stores REG_SZ, so together they flatten dynamic entries such as %JAVA_HOME%\bin and the default %USERPROFILE%\AppData\Local\Microsoft\WindowsApps into fixed paths.
The final SetEnvironmentVariable on an unused variable is a no-op write whose only purpose is the WM_SETTINGCHANGE broadcast. A direct registry write does not emit one, so without it the new PATH would not reach new terminals until the next logon.