mintty doesn't set terminal io properly
Opened this issue · 13 comments
This appears to be a bug in the msys mintty compile. I can run the same version of mintty (3.5.2) from cygwin and it works correctly.
Reproduce by starting MSYS2 MSYS from the start menu on Windows 10. The terminal window opens and bash starts correctly.
Run the windows version of python
python -c "import os,sys; print(os.isatty(sys.stderr.fileno()))"
and it returns False. Doing the same thing with cygwin returns True.
Possibly related?
When MSYS bash starts most of the windows path has been removed instead of converted. All that gets converted is
/c/Windows/System32
/c/Windows
/c/Windows/System32/Wbem
/c/Windows/System32/WindowsPowerShell/v1.0
I don't know if this is by design or a problem.
msys2 does not enabled ConPTY feature by default. Whereas cygwin does. To enable ConPTY by-default in msys2, close all the msys2 terminal windows, set MSYS=enable_pcon
variable in Control Panel, then run any msys2 terminal.
What do you mean enable the variable in the Control Panel?
Do you mean add it to the system or user environment variables?
What is the reason for not enabling ConPTY by default?
Do you mean add it to the system or user environment variables?
Yes, systempropertiesadvanced.exe
What is the reason for not enabling ConPTY by default?
Some programs like autotools, git etc. have issues with it. But things are being fixed quickly.
Run the windows version of python
Which python are you running? What does python -c "import sys; print(sys.version)"
show?
Which python are you running?
I am running python310 from an install on Windows.
What does python -c "import sys; print(sys.version)" show?
3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
I found that there is a mingw64.ini and an msys2.ini that have MSYS2_PATH_TYPE=inherit
commented out. I assume that I can un-comment it and bash will inherit the windows path.
I also added MSYS=enable_conpty
but that didn't seem to work to enable tty in python.
BTW, I am only looking at msys2 for a solution because I use git-bash from Git for Windows which is based on msys2. That is where I first found the problem.
Is there a list somewhere of all the config variables that can be used in msys2.ini?
I've wanted to document the options that are allowed in MSYS environment variable, but haven't found time to do so. The closest thing that exists is the documentation for the corresponding CYGWIN variable for cygwin: https://cygwin.com/cygwin-ug-net/using-cygwinenv.html. But there are some differences/additions in msys2.
I also added
MSYS=enable_conpty
but that didn't seem to work to enable tty in python.
it's enable_pcon
not conpty
I just found out that the shortcut created in the start menu during installation is a special terminal shortcut with a terminal tab. It doesn't read config file in C:\msys64\mingw64.ini. If I just run "C:\msys64\mingw64.exe" it does read the config file and MSYS2_PATH_TYPE=inherit
works.
I also added
MSYS=enable_conpty
but that didn't seem to work to enable tty in python.it's
enable_pcon
not conpty
I mistyped. This is what I have in the ini file
MSYS=enable_pcon
BTW, I am only looking at msys2 for a solution because I use git-bash from Git for Windows which is based on msys2. That is where I first found the problem.
In Git for Windows there is an option in the installer.
I just found out that the shortcut created in the start menu during installation is a special terminal shortcut with a terminal tab. It doesn't read config file in C:\msys64\mingw64.ini. If I just run "C:\msys64\mingw64.exe" it does read the config file and
MSYS2_PATH_TYPE=inherit
works.
My mistake, it does read the ini file, but it overrides the MSYS2_PATH_TYPE=inherit
from .ini file, because it is running C:\msys64\msys2_shell.cmd -msys
.
The good news, is that I found the correct variable to set isatty=True and it can be put in the .ini files in c:\msys64\
or in ./config/mintty/config
in my home directory.
The variable is ConPTY=on
BTW, the list of all the mintty config variable is at https://mintty.github.io/mintty.1.html#CONFIGURATION