Skip to content

Conversation

@cspotcode
Copy link

@cspotcode cspotcode commented Dec 1, 2025

winpty aliases cause some issues (see linked issue) and aren't necessary outside of mintty, so I tweaked the conditional to detect mintty and excludes Windows Terminal, VSCode terminal, and other modern windows terminals that export TERM=xterm-256color.

git-for-windows/git#5960

Other detection techniques I considered

I considered checking tty -s but it returns exit code 0 everywhere, in both mintty and Windows Terminal. Plus, it would require access to tty on the path (usually true but maybe sometimes not?) and would mean an extra process spawn in the profile which slows down startup.

I checked all env vars in both terminals, and TERM_PROGRAM is the only one that seems viable. MSYSTEM is set in both mintty and Windows Terminal.

Code review questions

Did I write the bash syntax correctly? I'm not using any bash-specific syntax that might break in unique configurations, and I'm not going to trigger errors if the shell has set -u?

Aliases cause a few issues and aren't necessary outside of mintty, so this check detects mintty but excludes Windows Terminal, VSCode terminal, and other modern windows terminals that `export TERM=xterm-256color`

Signed-off-by: Andrew Bradley <cspotcode@gmail.com>
@dscho
Copy link
Member

dscho commented Dec 1, 2025

/updpkgsums

The workflow run was started.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member

dscho commented Dec 1, 2025

In my tests, node.exe worked, even without winpty. Maybe this has changed with the default to using Pseudo Consoles? It would be so great if we could get rid altogether of that winpty dependency.

On the other hand, in my tests, python.exe still did not work without winpty (I am using v3.13 from the Microsoft Store), I cannot Ctrl+Z nor Ctrl+D out of the blank prompt when I call the interactive interpreter without winpty. Any ideas?

@cspotcode
Copy link
Author

cspotcode commented Dec 1, 2025

Are we talking about two different questions?

  • Question A) Is winpty necessary in Windows Terminal, VSCode integrated terminal, and other modern terminals?
    • As far as I know, "never necessary" which is the impetus for this PR
  • Question B) Is winpty necessary in mintty? If so, which programs require winpty in mintty?

@dscho
Copy link
Member

dscho commented Dec 1, 2025

Is winpty necessary in Windows Terminal, VSCode integrated terminal, and other modern terminals?

  • As far as I know, "never necessary" which is the impetus for this PR

Correct. winpty is not necessary when there is a real Win32 Console.

  • Is winpty necessary in mintty?

Originally, all regular Console programs required winpty when running in MinTTY. The reason is that MinTTY does not actually have a Win32 Console associated with its (emulated Unix) pseudo terminal, but relies purely on the POSIX emulation layer (provided by the MSYS2 runtime, which is a friendly fork of the Cygwin runtime). winpty provides the bridge between, by creating a Win32 Console for the Console programs to use, and mapping them to the (emulated Unix) pseudo terminal of the MinTTY window.

Some time ago, Windows started to offer Pseudo Consoles, with the intention to provide enough functionality to make that emulated Unix pseudo terminal support obsolete. Cygwin started supporting these Pseudo Consoles, at first opt-in, then later as opt-out feature. I personally experienced so many issues with Cygwin's Pseudo Console support that I held out a lot longer than Cygwin, making the Pseudo Consoles the default in Git for Windows only much much later than Cygwin. Today, it is the default, though.

Which was the reason why I tried running node.exe directly in a Git Bash (using MinTTY), and it worked!

I also tried tclsh.exe which also worked. I would have tried interactive OpenSSL, as mentioned in Git for Windows' known issues about Console programs requiring winpty, but this mode [was removed in OpenSSL v3.0](https://docs.openssl.org/3.0/man1/openssl/#:~:text=was removed in OpenSSL 3.0).

If so, which programs require winpty in mintty?

So far, the only program I tried that did require was Microsoft Store's Python. I do not quite understand why that is, though. Given my understanding of Pseudo Consoles, it should work.

@jeremyd2019
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants