Update PATH envrionment variable for package manager executable on Windows by daxian-dbw · Pull Request #25847 · PowerShell/PowerShell
daxian-dbw
added
the
CL-General
label
Aug 11, 2025SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request
Dec 12, 2025…ndows (PowerShell#25847) Implementation for PowerShell/PowerShell-RFC#391. A few implementation decisions: 1. Check the package manager list only once per process (**same as CMD**). So, changing the package manager list in registry doesn't affect a PowerShell session that is already running. 2. When detecting user/system PATH value changes, only check new items PREPENDED or APPENDED to the original string (**same as CMD**). The detection is made simple, which is not intended to detect complex changes to the user/system PATH. 3. The PATH update feature is disabled when the `Environment` provider is not available, or when the current session is restricted. - Both `Environment` provider and `IsSessionRestricted` are checked only once per PowerShell session. - Use `ConditionalWeakTable` to cache whether the feature is enabled or not for a given session. - We cannot use `thread-static` variable for the caching because it's possible for Runspace to reuse threads.
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