mintty / wsltty

Mintty as a terminal for Bash on Ubuntu on Windows / WSL
Other
3.11k stars 104 forks source link

wsltty won't start with wsl2 version 2.0.0 #342

Closed yamam closed 1 year ago

yamam commented 1 year ago

After updating to wsl 2.0.0 with the command wsl --install --pre-release, wsltty will not start. https://github.com/microsoft/WSL/releases/tag/2.0.0

mintty commented 1 year ago

@Biswa96, is this related to #327 or to #316 or is it a new issue?

SLKun commented 1 year ago

Same issue here. I think it is a new issue. @mintty

me-and commented 1 year ago

I'm also seeing this behaviour. It looks like there was some update to Windows or WSL that's relevant: the point at which WSLtty stopped working, Windows added a WSL icon marked "New" to my Start Menu.

Based on timings, it may be related to one of the following Windows updates, taken from the Windows Update history; the links – including the broken ones – are the corresponding "Learn more" links from Windows Update.

I'm currently seeing this on my Windows 11 Enterprise system running 23H2 build 22631.2338 with experience pack 1000.22674.1000.0 on the Beta Windows Insider track. WSL version info:

PS C:\Windows\System32> wsl --version
WSL version: 2.0.0.0
Kernel version: 5.15.123.1-1
WSLg version: 1.0.57
MSRDC version: 1.2.4485
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25880.1000-230602-1350.main
Windows version: 10.0.22631.2338

Attempting to run WSLtty with a shortcut pointing to %LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL="Debian" --configdir="%APPDATA%\wsltty" -~ -h always - produces a WSLtty window with the following message:

/bin/wslbridge2: Exit 1.
note: wsl.exe output: Failed to attach disk 'C:\Users\adinwoodie\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\ext4.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_SHARING_VIOLATION

WSL doesn't think the distro is running at the time; the following commands were run in a PowerShell session immediately before and after running the previous shortcut:

PS C:\Windows\System32> wsl --list --running
There are no running distributions.
PS C:\Windows\System32> wsl --list --running
There are no running distributions.
Biswa96 commented 1 year ago

wslbridge2 uses undocumented COM interface in WSL. WSL version 2.0.x changed that COM interface. So, wslbridge2 now fails. I do not know if or how the issue can be fixed. Suggestions are welcomed.

yamam commented 1 year ago

Is there a workaround, like running cmd.exe in mintty and then running wsl? I have mintty.exe %COMSPEC% command to launch cmd.exe and then tried to launch wsl, but wsl would not launch.

mintty commented 1 year ago

It's not necessary to go via cmd.exe, you can as well run wsl.exe in mintty directly: mintty wsl [-d DISTRO ]. This works on two of my systems but not on a third. I don't know why.

TurnOffNOD commented 1 year ago

I'm also seeing this behaviour. It looks like there was some update to Windows or WSL that's relevant: the point at which WSLtty stopped working, Windows added a WSL icon marked "New" to my Start Menu.

Based on timings, it may be related to one of the following Windows updates, taken from the Windows Update history; the links – including the broken ones – are the corresponding "Learn more" links from Windows Update.

* [2023-09 .NET 6.0.22 Security Update for x64 Client (KB5030559)](https://github.com/dotnet/core/blob/main/release-notes/README.md)

* [2023-09 .NET 7.0.11 Security Update for x64 Client (KB5030560)](https://github.com/dotnet/core/blob/main/release-notes/README.md)

* [Update Stack Package - (Version 1201.2307.25022.0)](https://support.microsoft.com/help/5029973) (broken link)

* [2023-09 Cumulative Update for .NET Framework 3.5 and 4.8.1 for Windows 11, version 22H2 for x64 (KB5031217)](https://support.microsoft.com/en-gb/topic/september-12-2023-kb5031217-cumulative-update-for-net-framework-3-5-and-4-8-1-for-windows-11-version-22h2-36af391a-81d4-4688-aa7e-3953a9831a58)

* [Cumulative Update for Windows 11 Insider Preview (10.0.22631.2338) (KB5030305)](https://support.microsoft.com/help/5030305) (broken link)

I'm currently seeing this on my Windows 11 Enterprise system running 23H2 build 22631.2338 with experience pack 1000.22674.1000.0 on the Beta Windows Insider track. WSL version info:

PS C:\Windows\System32> wsl --version
WSL version: 2.0.0.0
Kernel version: 5.15.123.1-1
WSLg version: 1.0.57
MSRDC version: 1.2.4485
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25880.1000-230602-1350.main
Windows version: 10.0.22631.2338

Attempting to run WSLtty with a shortcut pointing to %LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL="Debian" --configdir="%APPDATA%\wsltty" -~ -h always - produces a WSLtty window with the following message:

/bin/wslbridge2: Exit 1.
note: wsl.exe output: Failed to attach disk 'C:\Users\adinwoodie\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\ext4.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_SHARING_VIOLATION

WSL doesn't think the distro is running at the time; the following commands were run in a PowerShell session immediately before and after running the previous shortcut:

PS C:\Windows\System32> wsl --list --running
There are no running distributions.
PS C:\Windows\System32> wsl --list --running
There are no running distributions.

The same issue.

mintty commented 1 year ago

Following discussions in #343 which seems to be a duplicate, I've added a hint to use WSL V1 to the project page. Two questions: does it help for you

  1. to have a native instance of WSL running and then start a wsltty terminal?
  2. to set a WSL distribution to WSL V1 (e.g. wsl --set-version Ubuntu 1)?
rluetzner commented 1 year ago

Not sure if it helps, but after I ran into this myself yesterday, I tried different Terminal Emulators to see if they would work. Cmder runs into similar issues, but with another error message.

Of course the Microsoft Windows Terminal works perfectly, which is to be expected. But if I remember correctly the source code for that should be openly available on GitHub. Maybe there's a hint in it how to solve this issue.

xuefer commented 1 year ago

Following discussions in #343 which seems to be a duplicate, I've added a hint to use WSL V1 to the project page. Two questions: does it help for you

  1. to have a native instance of WSL running and then start a wsltty terminal?

nope, having wsl2 running from cmd

C:\>wsl
xuefer@localhost /mnt/c
$
c:\> wsl -l -v
  NAME      STATE           VERSION
* Ubuntu    Running         2
c:\> mintty.exe --WSL=  --configdir="%APPDATA%\wsltty" -~ --hold=always
ERROR: GetVmId:294: CreateLxProcess: The process cannot access the file because it is being used by another process.

subsequence retries give different error from the first one above

c:\> mintty.exe --WSL=  --configdir="%APPDATA%\wsltty" -~ --hold=always
/bin/wslbridge2: Exit 1.
it is being used by another process.
hayatogh commented 1 year ago

I encountered this problem today.

In my several experiment, failed attempt to open wsltty causes The process cannot access the file because it is being used by another process. error. After that, even plain wsl.exe calls fail for a few minutes. To test other commands listed below, I had to make sure plain wsl.exe working.

%LOCALAPPDATA%\wsltty\bin\mintty.exe wsl launches bash but looks like without pty(?).

Finally, I thought if the problem is in wslbridge2 side, plain mintty might work. C:\msys64\usr\bin\mintty.exe wsl looks like working, which is obtained from msys2 installation. This mintty invokation accepts only a subset of options: -i (icon) -t (title) option works, changing directry options not. I don't know how to test terminals but at least bash, vim and screen look like working to me.

Tested with mintty(3.6.4, 3.7.0), wsltty(3.6.4)

mintty commented 1 year ago

Thanks for additional testing. Also this may be helpful in case someones wants to dig into the issue:

After that, even plain wsl.exe calls fail for a few minutes.

Yes, mintty wsl works directly but then as seen from the WSL side, the terminal isn't really mintty anymore as the bothersome Windows ConPTY layer interferes with communication, see also https://github.com/mintty/mintty/issues/1166#issuecomment-1180319585

I have plans for an alternative way to access WSL. (I had plans for a while already but the conceived solution isn't really working nicely; I have a new plan now...)

l1n3n01z commented 1 year ago

AFAICT this is the same issue https://github.com/mintty/wsltty/issues/343 ?

There is now a workaround by downloading wslbridge2 cygwin nightly build as documented in the discussion. https://github.com/mintty/wsltty/issues/343#issuecomment-1822354091

mintty commented 1 year ago

Released 3.7.0.2.

aquohn commented 10 months ago

I am still encountering this issue on WSL 2.0.9.0 (which is the version distributed by the Microsoft Store) and wsltty 3.7.0.2. It does not occur with WSL 1 though.

Biswa96 commented 10 months ago

It is not feasible to test wsltty with every versions of WSL. Please try with the latest WSL from here https://github.com/microsoft/WSL/releases

CodeSpartan commented 10 months ago

The latest version currently being 2.0.14, it still occurs for me.

Biswa96 commented 10 months ago

I have tried WSL version 2.0.14 from here https://github.com/microsoft/WSL/releases/tag/2.0.14 in Windows 11. It works fine with latest wsltty.

Please try to check the wslbridge2 version with the following command.

%LocalAppData%\wsltty\bin\wslbridge2.exe -h

The output should have v0.12 in first line.

CodeSpartan commented 10 months ago

It's v0.12

Biswa96 commented 10 months ago

Could you provide any error message or explain what happens after you run wsltty? Also, does %LocalAppData%\wsltty\bin\wslbridge2.exe command show prompt from WSL?

DanKaplanSES commented 10 months ago

TL;DR: I installed the latest wsltty and it fixed my problems.

Everything below describes my symptoms and the steps I took to get to the solution. I'm not sure if I should even post it, but I figure the keywords within it may improve search engine results when users experience the same issues I experienced.


@mintty I ran wsl.exe --update this morning and started getting similar symptoms described by @me-and

Some differences:


* Unfortunately, as I was typing this I noticed I got changes by running wsl.exe --update again, and this completely changed my symptoms. Running wsl.exe hung for minutes until it eventually got into a terminal. While it was hanging, I opened up wsltty via shortcut, but all those terminals hung and continued to hang for 10+ minutes after the wsl.exe. During this time, the windows were unreactive to attempts to close them by clicking the "X" button or right clicking on their taskbar icon and choosing "Close."

When they eventually finished, they said /bin/wslbridge2: Exit 1., and nothing else. Oddly enough, they do respond to wsltty keyboard shortcuts I setup to close the windows. I'm not sure if this would have occurred before I got this error message, but it works now. If I tried to open a new wsltty terminal, they still hang like I described before.

This is my shortcut target field: %LOCALAPPDATA%\wsltty\bin\mintty.exe --tabbar=4 -o "KeyFunctions=t:new-window-cwd;w:close" --WSL="Ubuntu" --configdir="%APPDATA%\wsltty" -h always -.