Repository navigation
Open
Labels
Issue-BugIt either shouldn't be doing this or needs an investigation.
Description
After a recent Windows 11 26H2 upgrade, new shells stop loading the user PATH from the registry, so winget and other user-scoped tools vanish from cmd, PowerShell 5.1, and PowerShell 7 even though App Installer and winget.exe are still installed.
Environment
- OS: Windows 11 26H2 (build 10.0.26300)
- App Installer / winget: Microsoft.DesktopAppInstaller 1.29.380 (package status OK)
winget.exeat%LOCALAPPDATA%\Microsoft\WindowsApps\winget.exeruns when invoked by full path (winget --version→ v1.29.380)- User
PATHin registry (HKCUEnvironment\Path): ~3,632 characters, includes%LOCALAPPDATA%\Microsoft\WindowsAppsand 13...\Microsoft\WinGet\Packages\...entries (typical winget portable install pattern without Developer Mode / admin Links layout)
Steps to reproduce
- Accumulate a large user
PATH(common with multiple winget portable/zip packages that each append a longWinGet\Packages\...segment). - Upgrade to Windows 11 26H2 (or open a new cmd / PowerShell 5.1 / pwsh session after upgrade).
- Run
where wingetin cmd orGet-Command wingetin PowerShell 5.1 or pwsh. - Compare
[Environment]::GetEnvironmentVariable('Path','User')(registry) vs$env:Pathin the same process.
Expected
- User
PATHfrom HKCU is merged into every new interactive shell (cmd, PowerShell 5.1, pwsh). wingetresolves via the App Execution Alias underWindowsAppswhen App Installer is installed.- If a platform limit applies, Windows should surface a clear error or warning when user
PATHcannot be applied — not silently drop the entire user block.
Actual
- Registry user
PATHlength ~3632; processPATHlength ~1326 (matches machine PATH only — user PATH not applied at all). where wingetin cmd: not found.Get-Command wingetin PowerShell 5.1 and pwsh: not found.- Direct invocation still works:
& "$env:LOCALAPPDATA\Microsoft\WindowsApps\winget.exe" --version. - PowerShell profile import of
Microsoft.WinGet.CommandNotFoundfails at startup becauseValidateOS.psm1requiresGet-Command wingetto succeed.
Related
- winget-cli #3601 — PATH bloat from portable installs
- winget-cli #5557 — repeated WinGet package PATH entries vs 2047 limit
- winget troubleshooting: missing
%LOCALAPPDATA%\Microsoft\WindowsAppsin PATH (docs)
Ask
- OS: Fix or document behavior when user
PATHexceeds legacy limits — do not silently omit the entire user PATH from new processes. - winget: Default to Links/symlink layout where possible; warn when appending another
Packages\...segment would exceed safe PATH size; offer cleanup for duplicate or stale entries. - Visibility: A high-signal diagnostic (e.g.
winget doctoror Settings) when App Execution Aliases exist but PATH was not applied.
Workaround (local)
- Shorten HKCU
PATH(dedupe, remove per-package WinGet paths, keepWinGet\Links+WindowsApps) and sign out / reboot. turso config set autoupdate off-style:wingetonly via full path until PATH is repaired.
Activity
AMDphreak commentedon Oct 20, 2026
Fix the PATH size limitation.
R-Adrian commentedon Oct 21, 2026
when you refer to those new shells, are you running them elevated and the Administrator Protection GPO is enabled?
If so then it probably uses the HKCU of the elevated profile and not the HKCU of the regular profile.
SunnyLeu commentedon Nov 7, 2026
I investigated a very similar issue and reproduced the complete loss of the User PATH on three Windows 11 installations. My findings strongly suggest that this behavior originates from Windows Shell32's environment-regeneration logic rather than WinGet itself.
1. Controlled reproduction on Windows 11 24H2
I performed controlled tests on a relatively clean Windows 11 24H2 virtual machine:
shell32.dllversion: 10.0.26100.4768The following results were observed:
Screenshot — original 4095-character failure:
Additional tests established that:
REG_SZandREG_EXPAND_SZUser PATH registry values.CreateEnvironmentBlocksuccessfully constructed the complete PATH from the same registry values, including lengths exceeding 4095 characters.shell32.dll!RegenerateUserEnvironmentfunction returnedTRUEeven when the entire User PATH was omitted.Test evidence
The VM testing covered 24 controlled runs across multiple target lengths and both registry value types.
These files contain results from the actual VM experiments, not simulated output.
2. Independent reproduction on Windows 11 26H2
I also tested two Windows 11 26H2 installations:
shell32.dllversion: 10.0.26100.9949The results were consistent with the VM findings:
Remote PC: The exact 4094/4095 boundary was independently reproduced, with a Machine PATH length of 1144 characters. The combined PATH was correct at 4094 characters, but at 4095 characters the regenerated PATH contained only the Machine portion.
Primary PC: The existing combined Process PATH was 4162 characters. Calling
RegenerateUserEnvironmentproduced a Machine-only PATH of 2204 characters. The exact 4094/4095 boundary was not separately tested on this PC.These observations indicate that the problem is not limited to the particular 24H2 VM or to systems with ExplorerPatcher installed.
3. Root-cause investigation
Using WinDbg on the clean Windows 11 24H2 VM, I traced the failing behavior to a length check inside:
shell32!BuildEnvironmentPathAt the 4095-character boundary, the relevant conditional branch is taken, causing the function to skip the operation that appends the User PATH.
Controlled debugging, including an in-memory branch modification within a disposable VM process, provided strong causal evidence that this length check is responsible for the observed behavior.
Detailed debugger evidence has been submitted privately to Microsoft for further assessment.
For clarity, the instruction-level investigation was performed on
shell32.dllversion10.0.26100.4768(Windows 11 24H2). The two 26H2 installations reproduced the observable failure, but their internal machine code was not independently disassembled.4. Relevance to this WinGet issue
The symptoms described in this issue are highly consistent with the behavior I reproduced:
HKCU\Environment\Path.However, I cannot independently confirm that the original reporter's system has the exact same underlying cause without equivalent diagnostics.
Regarding elevation and Administrator Protection
A previous comment asked whether the problem might be related to elevated shells or Administrator Protection.
My clean-VM reproduction used a standard, non-elevated PowerShell process. Therefore, elevation or Administrator Protection is not required to reproduce this particular Shell32 environment-regeneration failure.
Why this matters beyond WinGet
This behavior can affect any application, developer tool, or automation script that relies on executable directories in the User PATH.
Although WinGet portable package installations may contribute to PATH growth, the demonstrated failure occurs within Windows Shell32's environment-regeneration logic.
5. Suggested follow-up
I recommend:
The most concerning aspect is that the User PATH can disappear from the regenerated environment without an error being reported by
RegenerateUserEnvironment.I hope the controlled reproduction results and attached evidence help identify the underlying Windows component and route the issue to the appropriate engineering team.