PATH not getting constructed correctly #19972

Closed
opened 2026-01-31 06:59:02 +00:00 by claunia · 5 comments
Owner

Originally created by @sotteson1 on GitHub (May 25, 2023).

Windows Terminal version

1.18.1421.0

Windows build number

10.0.22621.0

Other Software

No response

Steps to reproduce

If I launch the new preview terminal, it appears to not be expanding my PATH correctly. This causes apps I regularly use to not be launchable from my terminal.

Expected Behavior

Notice how the bolded items are properly expanded by the release version of terminal:

1.16.10262.0:
C:\Program Files\PowerShell\7;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Python310\Scripts;C:\Python310;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;C:\Program Files\Go\bin;C:\Program Files (x86)\dotnet-core-uninstall;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\Modules\TShell\TShell;C:\Program Files\PowerShell\7;C:\Program Files\Git\cmd;C:\Users\sotteson\AppData\Local\Microsoft\WindowsApps;C:\Users\sotteson.dotnet\tools;C:\Users\sotteson\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sotteson\AppData\Roaming\npm;D:\data\steve\OneDrive\bin;C:\Users\sotteson\go\bin;C:\Program Files (x86)\GnuWin32\bin;C:\msys64\mingw64\bin

Actual Behavior

The bolded items are not properly expanded.

1.18.1421.0:
C:\Program Files\PowerShell\7;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Python310\Scripts;C:\Python310;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;C:\Program Files\Go\bin;C:\Program Files (x86)\dotnet-core-uninstall;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\Modules\TShell\TShell;C:\Program Files\PowerShell\7;C:\Program Files\Git\cmd;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;%USERPROFILE%.dotnet\tools;C:\Users\sotteson\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sotteson\AppData\Roaming\npm;D:\data\steve\OneDrive\bin;%USERPROFILE%\go\bin;C:\Program Files\Go\bin;C:\Program Files (x86)\GnuWin32\bin;C:\msys64\mingw64\bin;

Originally created by @sotteson1 on GitHub (May 25, 2023). ### Windows Terminal version 1.18.1421.0 ### Windows build number 10.0.22621.0 ### Other Software _No response_ ### Steps to reproduce If I launch the new preview terminal, it appears to not be expanding my PATH correctly. This causes apps I regularly use to not be launchable from my terminal. ### Expected Behavior Notice how the bolded items are properly expanded by the release version of terminal: 1.16.10262.0: C:\Program Files\PowerShell\7;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Python310\Scripts\;C:\Python310\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Go\bin;C:\Program Files (x86)\dotnet-core-uninstall\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\Modules\TShell\TShell\;C:\Program Files\PowerShell\7\;C:\Program Files\Git\cmd;**C:\Users\sotteson\AppData\Local\Microsoft\WindowsApps;C:\Users\sotteson\.dotnet\tools**;C:\Users\sotteson\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sotteson\AppData\Roaming\npm;D:\data\steve\OneDrive\bin;C:\Users\sotteson\go\bin;C:\Program Files (x86)\GnuWin32\bin;C:\msys64\mingw64\bin ### Actual Behavior The bolded items are not properly expanded. 1.18.1421.0: C:\Program Files\PowerShell\7;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Python310\Scripts\;C:\Python310\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Go\bin;C:\Program Files (x86)\dotnet-core-uninstall\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\Modules\TShell\TShell\;C:\Program Files\PowerShell\7\;C:\Program Files\Git\cmd;**%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;%USERPROFILE%\.dotnet\tools**;C:\Users\sotteson\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sotteson\AppData\Roaming\npm;D:\data\steve\OneDrive\bin;%USERPROFILE%\go\bin;C:\Program Files\Go\bin;C:\Program Files (x86)\GnuWin32\bin;C:\msys64\mingw64\bin;
Author
Owner

@sotteson1 commented on GitHub (May 25, 2023):

Looks like setting "compatibility.reloadEnvironmentVariables": false fixes it. I'm going to debug it and see if I can tell what's going on.

@sotteson1 commented on GitHub (May 25, 2023): Looks like setting "compatibility.reloadEnvironmentVariables": false fixes it. I'm going to debug it and see if I can tell what's going on.
Author
Owner

@zadjii-msft commented on GitHub (May 25, 2023):

Maybe the contents of

  • HKEY_CURRENT_USER\Environment
  • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

might be enlightening?

@zadjii-msft commented on GitHub (May 25, 2023): Maybe the contents of * `HKEY_CURRENT_USER\Environment` * `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment` might be enlightening?
Author
Owner

@sotteson1 commented on GitHub (May 25, 2023):

I figured it out. On my system, [HKEY_CURRENT_USER\Environment]Path is of type REG_SZ instead of REG_EXPAND_SZ. The code in env.h then won't expand it. I'm going to submit a simple PR that fixes it.

@sotteson1 commented on GitHub (May 25, 2023): I figured it out. On my system, [HKEY_CURRENT_USER\Environment]Path is of type REG_SZ instead of REG_EXPAND_SZ. The code in env.h then won't expand it. I'm going to submit a simple PR that fixes it.
Author
Owner

@DHowett commented on GitHub (May 25, 2023):

Thanks!

I'm surprised that it works elsewhere for you. There might be some double expansion going on that shouldn't.

The code in til/env was lifted and munged from RegenerateUserEnvironment (shell32, internal, reSearch will help :)) and I cannot recall whether it did this expansion...

@DHowett commented on GitHub (May 25, 2023): Thanks! I'm surprised that it works elsewhere for you. There might be some double expansion going on that shouldn't. The code in `til/env` was lifted and munged from `RegenerateUserEnvironment` (shell32, internal, reSearch will help :)) and I cannot recall whether _it_ did this expansion...
Author
Owner

@sotteson1 commented on GitHub (May 25, 2023):

Just took a look at that code...they're careful to always expand path variables even if it's REG_SZ. My fix should have the same result.

@sotteson1 commented on GitHub (May 25, 2023): Just took a look at that code...they're careful to always expand path variables even if it's REG_SZ. My fix should have the same result.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19972