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

mintty doesn't set terminal io properly #187

Open
julie777 opened this issue Feb 26, 2022 · 13 comments
Open

mintty doesn't set terminal io properly #187

julie777 opened this issue Feb 26, 2022 · 13 comments

Comments

@julie777
Copy link

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.

@Biswa96
Copy link
Member

Biswa96 commented Feb 26, 2022

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.

@julie777
Copy link
Author

julie777 commented Feb 26, 2022

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?

@Biswa96
Copy link
Member

Biswa96 commented Feb 26, 2022

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.

@Biswa96
Copy link
Member

Biswa96 commented Feb 26, 2022

Run the windows version of python

Which python are you running? What does python -c "import sys; print(sys.version)" show?

@julie777
Copy link
Author

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.

@julie777
Copy link
Author

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?

@jeremyd2019
Copy link
Member

jeremyd2019 commented Feb 26, 2022

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.

@jeremyd2019
Copy link
Member

I also added MSYS=enable_conpty but that didn't seem to work to enable tty in python.

it's enable_pcon not conpty

@julie777
Copy link
Author

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.

@julie777
Copy link
Author

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

@jeremyd2019
Copy link
Member

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.

@julie777
Copy link
Author

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

@julie777
Copy link
Author

BTW, the list of all the mintty config variable is at https://mintty.github.io/mintty.1.html#CONFIGURATION

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

No branches or pull requests

3 participants