-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Terminal Preview 1.3 breaks Windows PowerShell 5 (32-bit x86)'s history save and view and its command line colors #7418
Comments
This is absolutely wild. It looks like PowerShell (x86) has been working thanks to a fluke this whole time. Neat! |
The
On Windows Terminal 1.2 |
If I explicitly import |
It's very curious that PowerShell ships every module in both places except PSReadline. It is additionally concerning that this has simply worked forever (except perhaps there have been maybe ten users using weird configurations who have gotten the 32-bit module path and written it off as a fluke.) We can fix this by expanding the environment variables in our newly-minted block before passing them off, but ... I'd like to understand how PowerShell expected this to work 😄 |
Summoning @SteveL-MSFT - Do you have any idea why PSReadline is the special case here? |
I'm reverting the environment fix for 1.3's move to stable this week because we do not otherwise have a good solution for this. |
Revert "Fix environment block creation (#7401)" This reverts commit 7886f16. (cherry picked from commit e46ba65) Revert "Always create a new environment block before we spawn a process (#7243)" This reverts commit 849243a. References #7418 (cherry picked from commit 4204d25) (cherry picked from commit f8e8572)
Revert "Fix environment block creation (#7401)" This reverts commit 7886f16. (cherry picked from commit e46ba65) Revert "Always create a new environment block before we spawn a process (#7243)" This reverts commit 849243a. References #7418 (cherry picked from commit 4204d25) (cherry picked from commit f8e8572) (cherry picked from commit cb4c4f7)
Revert "Fix environment block creation (#7401)" This reverts commit 7886f16. (cherry picked from commit e46ba65) Revert "Always create a new environment block before we spawn a process (#7243)" This reverts commit 849243a. References #7418 (cherry picked from commit 4204d25) (cherry picked from commit f8e8572) (cherry picked from commit cb4c4f7) (cherry picked from commit afb0cac)
Revert "Fix environment block creation (#7401)" This reverts commit 7886f16. (cherry picked from commit e46ba65) Revert "Always create a new environment block before we spawn a process (#7243)" This reverts commit 849243a. References #7418 (cherry picked from commit 4204d25) (cherry picked from commit f8e8572) (cherry picked from commit cb4c4f7) (cherry picked from commit afb0cac) (cherry picked from commit b25dc74)
Windows PowerShell (and pwsh too but code was a bit updated) expands env variables in PSModulePath internally. So Windows Terminal has no need to expand env variables. I guess there was a bug in commit reverted. |
Unfortunately, Terminal launches many, many things that are not PowerShell. In general, though: Terminal is not expanding environment variables. It is using the system API¹ to generate a new environment block, which it then passes to the newly-spawned application. On launch with a new system environment block, PowerShell x86 receives a module path that contains When we use the old environment block, that value was already expanded, to ¹ The public one, which is clearly incorrect. |
@DHowett To be clear, PowerShell modify PSModulePath internally and write back to the process env block.
If we look in cmd.exe x32:
If we look in Windows PowerShell x64
If we look in Windows PowerShell x32
As you can see, PowerShell add new paths before old ones. You could run "broken" Windows Terminal version, start Windows PowerShell and run |
Indeed- Here's my PSModulePath: Here's what CMD Says: and of course, here's what PowerShell x86 says: And for good measure: Anyway, that's the central thesis of this issue. When PowerShell x86 expands When PowerShell (x86) is launched from Explorer, it never sees When PowerShell (x86) is launched from Task Manager it has the same problem as Terminal (!). As noted on Aug 26, 2020... "PowerShell x86 has been working properly due to a fluke this whole time" |
Ah! Thanks! Now I can reproduce. Although it has nothing to do with this issue at all :-))))) This is the rare case when a simple problem suddenly cloudes our understanding. What is the user really ask in the issue? - "Why I can not load x86 dll in x64 process?" Should I add more words? :-) Ok! PS modules can contain dll-s. So for the issue answer should be: PS: pwsh works the same. |
Ah, but here's the catch! Open up a working x86 PowerShell and ask it where PSReadline has been loaded from. PSReadline is an architecture-agnostic .NET assembly with no native PAL DLL! When x86 PowerShell accidentally loads the "x64" PowerShell's PSReadline, it works properly. That's how the issue of the module path expansion has been hiding this whole time. |
Yes, most modules are like that. I don't even know if we can find a module that is x86 :-) Now everything is x64. So we shouldn't even ask PS x86 to be smarter. |
And I think you can bring back the reverted commit so that we get more useful feature than that PS x86 by-design issue workaround. |
Unfortunately, any shell breaking when launched by Terminal when it doesn't break when launched by Explorer (Start Menu, Run dialog, desktop shortcut) is an unacceptable failure case for us! We want to make the console experience on Windows better, not worse. 😄 Like... if it didn't break the first thing a user would do with the shell (like, type a command...) I would be more forgiving. But no- we need to do our best to make the out of box experience perfect. |
I see your point. But:
You could add a workaround in WT itself (run by cmd.exe?). But the main thing is that you give up a really useful feature that is needed by a large number of users. |
Revert "Fix environment block creation (#7401)" This reverts commit 7886f16. (cherry picked from commit e46ba65) Revert "Always create a new environment block before we spawn a process (#7243)" This reverts commit 849243a. References #7418 (cherry picked from commit 4204d25) (cherry picked from commit f8e8572) (cherry picked from commit cb4c4f7) (cherry picked from commit afb0cac) (cherry picked from commit b25dc74)
Revert "Fix environment block creation (#7401)" This reverts commit 7886f16. (cherry picked from commit e46ba65) Revert "Always create a new environment block before we spawn a process (#7243)" This reverts commit 849243a. References #7418 (cherry picked from commit 4204d25) (cherry picked from commit f8e8572) (cherry picked from commit cb4c4f7) (cherry picked from commit afb0cac) (cherry picked from commit b25dc74) (cherry picked from commit 5f7c66b)
Revert "Fix environment block creation (#7401)" This reverts commit 7886f16. (cherry picked from commit e46ba65) Revert "Always create a new environment block before we spawn a process (#7243)" This reverts commit 849243a. (cherry picked from commit 4204d25) (cherry picked from commit f8e8572) (cherry picked from commit cb4c4f7) (cherry picked from commit afb0cac) (cherry picked from commit b25dc74) (cherry picked from commit 5f7c66b) Fixes #7418
🎉This issue was addressed in #12140, which has now been successfully released as Handy links: |
Environment
Windows build number: Microsoft Windows [Version 10.0.19042.422] for x64
Windows Terminal version (if applicable): 1.3.2382.0
Using the default Terminal settings.json file and without any PowerShell profile files.
Steps to reproduce
wt.exe
in Settings -> Apps -> Apps and features -> App execution aliases, and log out and log in if needed to make the setting fully take effect.wt.exe "C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe"
get-help gv -ful
with one L, press Tab.get-help gv -Full
with 2 letters L, and the colors of that string.Expected behavior
get-help
command you ran,get-help
was in yellow and-Full
was in a darker shade of gray than the other text.get-help
command you just ran.Actual behavior
get-help
command, all the text was the same color.get-help
command and other commands you ran in PowerShell within Terminal were not recorded in the history.The text was updated successfully, but these errors were encountered: