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

[MSYS] Ability to launch WSL from existing Mintty install? #271

Closed
rashil2000 opened this issue Jan 24, 2021 · 29 comments
Closed

[MSYS] Ability to launch WSL from existing Mintty install? #271

rashil2000 opened this issue Jan 24, 2021 · 29 comments
Labels

Comments

@rashil2000
Copy link

I use MSYS and the terminal Mintty that comes with it. However, as is well known, Mintty doesn't support running Windows commandline apps (like cmd, powershell). So I can't launch WSL from inside Mintty.

Question is, will I need to download and install WSLtty separately for WSL? Is there a way I can configure my already-installed Mintty to run WSL (possibly by using scripts/files from this repository)?

@mintty
Copy link
Owner

mintty commented Jan 24, 2021

That is not correct. You can run e.g. cmd within mintty. You can also start a mintty window with full WSL support: mintty --WSL=, optionally selecting a WSL distribution with a parameter value.
You can also configure a WSL session launcher item into your context menu, see https://github.com/mintty/mintty/wiki/Tips#supporting-linuxposix-subsystems.

@mintty
Copy link
Owner

mintty commented Jan 24, 2021

However, you'd need to install wslbridge2 into your system to make this work.
I'll check whether to improve documentation on how to do this.

@Biswa96
Copy link
Contributor

Biswa96 commented Jan 25, 2021

Mintty doesn't support running Windows commandline apps (like cmd, powershell).

mintty is a terminal emulator, so you can run any program there. But the question is will it work without any issue?

I use MSYS and the terminal Mintty that comes with it.

Do you mean msys2? If yes then you can run wsl.exe there. But before that, you have to set the global environment variable MSYS=enable_pcon to enable ConPTY feature.

But ConPTY does not support all characters (e.g. ♥♦♣♠). So, there are programs like socat, ssh, wslbridge, wslbridge2 etc.

@rashil2000
Copy link
Author

Hi!
So I tried running mintty --WSL=arch-linux, but it threw the error Failed to run '/bin/wslbridge2': No such file or directory.

However, you'd need to install wslbridge2 into your system to make this work.

You're right, how do I do this?

@rashil2000
Copy link
Author

mintty is a terminal emulator, so you can run any program there. But the question is will it work without any issue?

Exactly my point, the programs are in PATH, so they will start, but the I/O would not be what we usually expect. Let me give some examples to show this:

  1. The first is ssh. I'm just pressing arrow keys, nothing else. The upper window is mintty /c/Windows/System32/OpenSSH/ssh.exe [email protected], notice the initial error Pseudo-terminal will not be allocated because stdin is not a terminal. Even the shell prompt isn't shown at all. The lower window is mintty /usr/bin/ssh [email protected], which is working as expected.

hmmm

  1. The second is cmd. Upper window is mintty /c/Windows/System32/cmd.exe, lower is normal cmd.exe. Here too the shell prompt is missing, and arrow keys are misbehaving:

hmm2

  1. This one is powershell. Upper window is mintty /c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe, lower is normal powershell.exe. Notice the explicit errors.

hmm3

  1. The problem with WSL is similar, nothing is shown at all, and arrow keys misbehave.

@rashil2000
Copy link
Author

Do you mean msys2? If yes then you can run wsl.exe there. But before that, you have to set the global environment variable MSYS=enable_pcon to enable ConPTY feature.

Setting the value to 'enable_pcon' seems to have solved the issue.

May I ask what additional stuff wslbridge is providing?

@Biswa96
Copy link
Contributor

Biswa96 commented Jan 25, 2021

May I ask what additional stuff wslbridge is providing?

wslbridge and walbridge2 just grab the buffer from WSL side and spit it to Windows side and vice versa. No extra processing in-between. But ConPTY does some.

@rashil2000
Copy link
Author

Is there a reason MSYS=enable_pcon is not set by default on MSys2/Mintty? Does it break some stuff?

@mintty
Copy link
Owner

mintty commented Jan 25, 2021

You may ask them:)
Actually, one reason might be this: Throughout cygwin 3.1.*, ConPTY support is enabled by default, not only for Windows programs, but always active, i.e. also for cygwin programs, which unfortunately has some performance impact on their terminal output. This shall be fixed with cygwin 3.2, with unknown release date though.

@Biswa96
Copy link
Contributor

Biswa96 commented Jan 25, 2021

Does it break some stuff?

Yes, it breaks some stuff. Here is the commit in msys2 which makes the ConPTY feature as opt-in msys2/msys2-runtime@22ba7ac. Also if you search conpty in any msys2 packaging repository you could find related issues. Personally, I get some overlapping while building projects with mingw-w64-cmake in msys2/MINGW-packages.

@Biswa96
Copy link
Contributor

Biswa96 commented Jan 25, 2021

Speaking of the actual question here, I have added a wslbridge2 release compiled with msys2 https://github.com/Biswa96/wslbridge2/releases. Just download, extract, run wslbridge2.exe in msys2. ConPTY is NOT required.

@rashil2000
Copy link
Author

Does it break some stuff?

Yes, it breaks some stuff. Here is the commit in msys2 which makes the ConPTY feature as opt-in msys2/msys2-runtime@22ba7ac. Also if you search conpty in any msys2 packaging repository you could find related issues. Personally, I get some overlapping while building projects with mingw-w64-cmake in msys2/MINGW-packages.

Thanks for this. I noticed some issues with it too. Like, I ran mintty cmd then opened up neovim, and it had registered some keystrokes by itself (see bottom)

image

Speaking of the actual question here, I have added a wslbridge2 release compiled with msys2 https://github.com/Biswa96/wslbridge2/releases. Just download, extract, run wslbridge2.exe in msys2. ConPTY is NOT required.

Sure, I'll check it out!

@mintty
Copy link
Owner

mintty commented Jan 25, 2021

... run wslbridge2.exe in msys2.

Or copy the two wslbridge2 binaries (frontend and backend) into your /bin directory to enable full WSL-related feature support via mintty --WSL.

@rashil2000
Copy link
Author

... run wslbridge2.exe in msys2.

Or copy the two wslbridge2 binaries (frontend and backend) into your /bin directory to enable full WSL-related feature support via mintty --WSL.

That's what I did, thanks!

So should I close this now?

@mintty
Copy link
Owner

mintty commented Feb 9, 2021

Actually, the mintty wiki already describes how to set up wslbridge2 to support launching WSL in mintty from cygwin or MSYS2:
https://github.com/mintty/mintty/wiki/Tips#manual-setup-of-wsl-terminal

@mintty mintty closed this as completed Feb 9, 2021
@mintty mintty changed the title Ability to modify existing Mintty install? Ability to launch WSL from existing Mintty install? Feb 9, 2021
mintty added a commit to mintty/mintty that referenced this issue Feb 9, 2021
@rashil2000
Copy link
Author

Just a quick unrelated question - this wsl bridge method works only for WSL, right? And not for linux systems through SSH?

@Biswa96
Copy link
Contributor

Biswa96 commented Feb 9, 2021

Here is a direct quote from actual wslbridge's README:

wslbridge is a Cygwin program that allows connecting to the WSL command-line environment over TCP sockets, as with ssh, but without the overhead of configuring an SSH server.

@rashil2000
Copy link
Author

Oh, okay, now it makes sense. Thanks!

@mintty
Copy link
Owner

mintty commented Feb 9, 2021

For remote ssh, wslbridge2 is not needed; just run ssh.

@rashil2000
Copy link
Author

I had this doubt because SSH from mintty was also problematic, before I set MSYS=enable_pcon

@mintty
Copy link
Owner

mintty commented Feb 9, 2021

You can also configure ssh shortcuts for the context menu session launcher and also for the taskbar icon as described in the manual.

@rashil2000
Copy link
Author

I've spent plenty of time customizing mintty (I absolutely love it for the sheer amount of SGR parameters it supports xD) - here's what I settled into:

Transparency=off
Font=RecMonoSemicasual NF
FontHeight=10
FontWeight=400
BoldAsFont=yes
BoldAsColour=no
Scrollbar=right
ConfirmExit=no
ThemeFile=google-light
Term=xterm-256color
BellType=0
TabBar=9
Icon=D:\Data\Pictures\Icons\bash.ico
SessionGeomSync=4
SessionCommands=Kali Linux:-i D:\Data\Pictures\Icons\kali-menu.ico wsl;Arch Linux:-i D:\Data\Pictures\Icons\archlinux.ico wsl -d arch-linux;Ubuntu - Azure:-i D:\Data\Pictures\Icons\ubuntuazure.ico ssh ubuntuazure;Ubuntu - OSBoxes:-i D:\Data\Pictures\Icons\Ubuntu.ico ssh ubuntuosboxes;
Columns=90
Rows=30

@mintty
Copy link
Owner

mintty commented Feb 9, 2021

I'm considering to add an option to enforce enabling ConPTY support, for use in combination with your remote SessionCommands entries on MSYS2.

@rashil2000
Copy link
Author

Yes, that might be helpful. One thing to note here is that I don't have OpenSSH installed on Msys2; the session commands here are using the ssh executable from Windows\System32 side.

@mintty
Copy link
Owner

mintty commented Feb 17, 2021

Released 3.4.5.

@rashil2000
Copy link
Author

rashil2000 commented Feb 14, 2023

Hi all!

Just wanted to follow up on this issue after this was posted: https://www.msys2.org/news/#2022-09-24-conpty-support-enabled-by-default

I still need to set MSYS=enable_pcon explicitly in order to avoid the issues mentioned in the recordings above. What seems to be the issue here? Do I need some specific versions of some packages?

@mintty
Copy link
Owner

mintty commented Feb 14, 2023

Just speculating:
I guess the changed default is only applied on fresh installation.
You might ask them whether it can be switched during update.

@rashil2000
Copy link
Author

I guess the changed default is only applied on fresh installation.

Okay, I downloaded a fresh tar file of MSYS2, and it works fine there.

You might ask them whether it can be switched during update.

Where should I post this question?

@mintty
Copy link
Owner

mintty commented Feb 14, 2023

You might ask them whether it can be switched during update.

Where should I post this question?

Don't know, look on their homepage.

@mintty mintty changed the title Ability to launch WSL from existing Mintty install? [MSYS] Ability to launch WSL from existing Mintty install? Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants