Skip to content
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

Win+R: wt launches a Windows Terminal that doesn't work for some apps. #7460

Closed
escape0707 opened this issue Aug 29, 2020 · 11 comments
Closed
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@escape0707
Copy link

escape0707 commented Aug 29, 2020

Environment

Windows build number: Windows_NT x64 10.0.19041.0
Windows Terminal version: 1.2.2381.0 1.3.2382.0

Any other software? VSCode Version: 1.48.2

Steps to reproduce

  1. Try run Windows Terminal by Win + R: wt or by search terminal in start menu and run or click to run.
  2. try run nvim or get-help | less
  3. try Ctrl + , and launch VSCode. In VSCode integrated terminal, try step 2.

Expected behavior

Neovim launches or less launches.

Actual behavior

When using stable version of Windows Terminal, if run with wt, nvim and less won't give any output. This appies to the integrated terminal in a VSCode launches by pressing Ctrl + , in Windows Terminal, too.
But if I launch Windows Terminal in the same way as other UWP, there is no problem.

When using preview version of Windows Terminal, this problem only exist when run with wt and launch VSCode by Ctrl + ,, and then try nvim or less in VSCode's intergrated terminal.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Aug 29, 2020
@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Aug 29, 2020

I think this is caused by #7204. As a workaround, you could rename or delete the Path value (not the default value) at HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe.

When using preview version of Windows Terminal, this problem only exist when run with wt and launch VSCode by Ctrl + ,

#7204 was fixed for the child processes that Windows Terminal starts for new tabs or panes, but Process Monitor shows that the Path change still leaks to the child process that Windows Terminal starts for editing the settings, and to C:\WINDOWS\system32\wsl.exe --list as well.

@KalleOlaviNiemitalo
Copy link

The Path change also propagates to the Web browser processes started by the Feedback menu item or by hyperlinks on the About screen.

I think it would be best to make wt.exe delete the installation directory from its in-process Path environment variable so that WindowsTerminal.exe never inherits it. That would prevent similar issues later in other features that start child processes.

@DHowett
Copy link
Member

DHowett commented Sep 2, 2020

I'd like to understand what part of having wt's application directory in PATH causes this. I can't reproduce it, and have never had an application fail to launch through WT unexpectedly.

What is your proposed method of action? @escape0707 you used the 👍 reaction on all of @KalleOlaviNiemitalo's comments; does that indicate that they fixed your issue?

@DHowett DHowett added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 2, 2020
@escape0707
Copy link
Author

escape0707 commented Sep 3, 2020

@KalleOlaviNiemitalo @DHowett Thank you for all you guys' investigation.

Yes, @KalleOlaviNiemitalo's workaround fix that problem. I renamed those two Path in regedit.exe to Path1 and it works like expected, under both situations described in the original post.

I think it might worth noting that I installed VSCode-portable and Neovim through scoop package manager. But as I try to invoke nvim directly by it's absolute path and still failed, I think it at least might not be a scoop only problem. I also installed oh-my-posh and made my own $Profile but I ensured I had removed them and tested again before filed this issue.

Another note: For Windows Terminal Preview, there is no HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\wt.exe, but change the other one is needed to workaround with this issue for me.

For this issue, I don't know where to find a proper log, as nvim just seems not being launched at all and no error message gived in terminal. VSCode-Vim do give an error as I enabled neovim for it and use nvim for neovim path. When this issue happens, VSCode gives this error when launched:

Configuration: Invalid neovimPath. Command failed: C:\Users\tothe\scoop\shims\nvim.exe 
--version.Tried to parse PATH C:\Users\tothe\scoop\shims\nvim.exe.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Sep 3, 2020
@KalleOlaviNiemitalo
Copy link

I don't know how the extra entry in Path causes the error, but given the conditions in which the error does or doesn't occur, it must be involved. (Or perhaps Path just becomes too long overall?)

@escape0707, can you use Process Monitor to check what Scoop's wrapper or Neovim itself loads from the Windows Terminal directory?

@escape0707
Copy link
Author

@KalleOlaviNiemitalo Will this be useful?
Logfile.zip

I run Process Monitor and add Process Name is nvim.exe to filter, clicked Clear, Win+R wt, nvim + Enter. And got this.

@escape0707
Copy link
Author

Logfile.zip
And this is what I set the filter to Parent PID is {WindowsTerminal.exe's PID}, Clear and run nvim got. Both this and the above post's log is for Windows Terminal, not the preview version.

@KalleOlaviNiemitalo
Copy link

From the logs, the problem seems related to vcruntime140.dll. The nvim.exe process manages to open C:\Users\tothe\scoop\apps\neovim\0.4.4\bin\vcruntime140.dll (a reparse point is involved) and calls NtCreateSection but then closes the file without a Load Image event. After that, it tries to open VCRUNTIME140.dll from several other directories. It successfully opens C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.2.2381.0_x64__8wekyb3d8bbwe\vcruntime140.dll for Read Attributes access but then gets an ACCESS DENIED error when trying to open that again for Execute access.

Can you also post a Process Monitor log of how nvim.exe starts successfully (e.g. in Windows Terminal Preview)?

Is C:\Users\tothe\scoop\apps\neovim\current a symbolic link or junction that points to C:\Users\tothe\scoop\apps\neovim\0.4.4?

Your computer does not appear to have C:\Windows\System32\VCRUNTIME140.dll. Perhaps installing Microsoft Visual C++ Redistributable would also work around this error, but similar errors might still occur with other DLLs.

@escape0707
Copy link
Author

escape0707 commented Sep 3, 2020

Logfile.zip

This is the successful run's log from Windows Terminal stable version invoked from Start menu app icon. And I followed your amazing way and discovered that this time neovim seems to be using python's vcruntime140.dll, which isn't what I expected...

C:\Users\tothe\scoop\apps\neovim\current is a symbolic link created by scoop to allow it to install, update and switch between each portable version of apps, etc. But I don't really understood too much of that.

I installed vcredist2019 and it works for Win+R+wt enviroment now. Thanks for your highly valuable time and effort! I literally have no experience about this kind of system and resources related problem.

I think I'll take care of installing vcredist later on when I use nvim or less on windows. And if this behavior is actually not a bug but expected consequence, maybe I should close this issue? I don't know it's because there is a reachable vcruntime140.dll provided by python added to the path that shadowed the fact of lacking a vcredist....

@KalleOlaviNiemitalo
Copy link

I think it's still a bug in Windows Terminal, which should not include its installation directory in the Path environment variable that child processes receive. Perhaps it's best to reopen #7204 as #7243 did not fix it for the settings editor and the about screen, and then close this one.

A separate bug report could be filed on Scoop, to let its maintainers investigate why the nvim.exe process tries to load vcruntime140.dll from Path even though it has a local C:\Users\tothe\scoop\apps\neovim\0.4.4\bin\vcruntime140.dll as well. Perhaps this is somehow caused by Scoop's symbolic link or by incorrect Authenticode signatures (a guess because NtCreateSection looked at HKLM\System\CurrentControlSet\Control\CI, i.e. Code Integrity).

@escape0707
Copy link
Author

I agree with you. I'll search in scoop repo for the dll problem later on and close this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

3 participants