-
Notifications
You must be signed in to change notification settings - Fork 2.7k
mintty issues #74
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
Comments
Unfortunately, most of the issues with native console programs are an ongoing and long-standing issue with mintty due to the way it implements standard streams and pipes and unlikely to be resolved any time soon. |
The short version, as I understand it, is that, in lieu of actual pseudo-terminal support on Windows, mintty implements the standard streams as named Windows pipes that programs can arbitrarily attach to. The problem is that programs that haven't been specifically compiled to support treating those particular streams as terminal streams will cause issues by treating them as pipes. See for example the patch in de0d35d to get Git to work properly in mintty. Most applications compiled under MSYS2 should automatically handle that, as it's part of the provided |
Given that I frequently use |
Oh, maybe the problem is something else entirely: @kblees by "git/msys" do you refer to Git for Windows 1.x? Sorry, it is not at all clear to me what your setup is, after reading the report again. |
Steps to reproduce:
Note that these issues are specific to mintty, native console windows work just fine (e.g. |
The only difference I see is that I open the second window by double-clicking the desktop icon of the Git SDK. And voilà, it works here. Maybe it would work that way on your side, too? |
Double-clicking the desktop icon starts a fresh shell, it loses the current directory and any additional environment settings that may be necessary to work on a project. |
That still does not answer my question whether that makes the pager work for you? |
Hmm, it looks like the issues with native console programs might be at least partially resolved if mintty adopts something similar to this code from winansi.c. It modifies the internal file handles such that native |
Interesting hack. But I think console programs running inside |
We've made this work fine for Julia's REPL by specifically checking for the pipe names that mintty uses here: https://github.com/JuliaLang/julia/blob/9ad3aa0813f8e4652c761ab010bbc537ac807b2a/src/jl_uv.c#L876-L904 It can be made to work, but as @dscho said it needs some special patching in the terminal/pipe handling of any program you want to fix. |
I wonder if it would be possible for mintty to hook the handle creation function for child processes and run that code before returning the handle. |
Maybe? It would probably need to be forked and experimented with. Last I checked with some Cygwin folks, mintty's author has been MIA for a while. |
I do not see how this could be changed on A solution on mintty's side would magically make MSVCRT's |
That is not a problem, thanks to the awesomeness called GitHub. |
I got a chance to test this (I actually only tested |
Sadly, this does not fix the issue. I fear we need to force a reinitialization of that environment variable somehow. |
...or go a different route: check if the name of the pipe matches '...msyspty' (at least that's how MSys2.dll does it). Sadly this requires the internal NtQueryObject API from ntdll.dll Considering that handles can be duplicated and closed (and closed handles can be reused for different kernel objects), the MSYS_TTY_HANDLES solution sounds a bit fragile. |
The idea of The problem we are facing here is that this environment variable is not reinitialized correctly. I have a hunch that the code path I am using is actually hit only once in the call stack (read: if a mintty launches another mintty, the code may not even be executed to set |
I don't think so. Handles are private to a process. The only exception would be inherited handles, which initially have the same value in parent and child process. But if the child process closes them, they can be reused for anything.
Perhaps MSys fork emulation uses DuplicateHandle to make extra sure that the handles are inheritable, but the If git launches another git, though (which I think is what the |
Hmm. In that case, we would have no way to determine whether a given stdin/stdout/stderr refers to a stream that is connected to mintty. Hmm.
good point. I'll look into that tomorrow.
Right. My current plan is to adjust |
This comment was marked as abuse.
This comment was marked as abuse.
@rcdailey you could investigate yourself by comparing the behavior and |
... and if you find something interesting, you might want to open a new Pull Request right away (this here ticket is about an entirely unrelated issue than you raised in your latest comment). |
The only differences between the set mark-symlinked-directories on I just tested on my system by typing "cd /c/ProgramD" and hitting tab. It completed immediately to |
This comment was marked as abuse.
This comment was marked as abuse.
There is a terminal emulator for windows, http://conemu.github.io/, that spawns native console hosts and hacks into them to manage the actual display. I've been using it for both cygwin and msysgit (1.x) for couple of years, basically since cygwin started pushing mintty, because I always needed native (compiled by somebody else with MSC++) programs to work. Perhaps it would be an option to use that terminal, some other terminal that implements the hack or point people at that terminal if they need to use native programs from git bash instead of using mintty. |
This comment was marked as abuse.
This comment was marked as abuse.
@jan-hudec @rcdailey this is really the wrong ticket to discuss these issues. The correct ticket to do so, in fact the ticket that already has this discussion, is here: #96. Let's keep discussions organized and head over to the appropriate place, and stay on topic in this ticket's discussion. |
I mean, since native programs have, and always will have, problems with mintty, why use it at all? What is the problem with using default console host (cmd.exe) like version 1 does? I mentioned ConEmu to suggest that if the problem with cmd.exe is that it is crap, it would be better solved by pointing people to ConEmu then by using mintty, which has it's own problems. |
This statement is so broad that it is necessarily incorrect. So let me restate what I think you intended to say:
That statement is correct and the question is valid. The answer is two-fold: If you have to run a program that requires a Win32 Console, you can do so by using the By the way, since the issue tracker together with VM struggles and actual development keeps me too busy to update the FAQ myself, I would appreciate it if you took the time to chisel what you learned into a kick-ass answer here: https://github.com/git-for-windows/git/wiki/FAQ |
@dscho, you still didn't say why use any replacement for the win32 console at all. For me, the win32 console is preferred because of encoding issues (msys and cygwin use utf-8, native programs use legacy codepages, so winpty is needed for anything that prints non-ascii, which is a lot of things for me). |
Ah, you're correct, of course. Sorry. Of the top of my head:
These are just a couple of really annoying things. To be sure, before releasing a Git for Windows 2.x, I want to add a page to the installer that lets you switch to the If mintty is hated universally enough, we will make the |
Thanks. The scroll-back, size and font are set in the shortcut, so that should be possible to set for Git Bash and I've learned to live with the mouse-only copy&paste. The rectangular selection is silly, I agree. I suppose use case like ours with a bunch of bash scripts calling native tools (for which msys is better then cygwin) is not that typical to make mintty universally hated. |
I forgot that, didn't I? Could you please patch https://github.com/git-for-windows/build-extra/blob/master/make-file-list.sh#L29-L32 and open a PR after testing that this does what you need? (I can't do that right now because my machine is running the Git test suite for another 1.5h or so) |
@dscho have you ever considered ConsoleZ? |
Yes. See #96 (comment) |
@kblees could you check whether the current |
@dscho Yes, d56d2f8 works fine for me, thanks. The shell solution can even handle non-ASCII usernames and passwords correctly. With And of course the MSYS_TTY_HANDLES patch could be removed from MSys2.dll |
...and probably also the |
git-for-windows/build-extra@36be391 and git-for-windows/build-extra@fd0095c.
Great! Thanks for testing.
I am actually reluctant to do that. There is a really good reason why the shell stuff is guarded behind an
Whoa, not so fast. First I need to release a new |
Even though it works much better than the CONIN$ / CONOUT$ stuff? See PR #141 how I think this could be done. But perhaps I'm missing a really important use case (MSVC perhaps?). |
Does it work even when invoked from git-cmd? |
Let's discuss the |
Another item for the list of "Issues with other (native) console programs" from the first post: For many native console programs the is-a-tty detection to determine whether they should output color does not work as expected inside mintty, i.e. no color is used. Examples are the Rake / Ruby and Gradle. Note that I'm not talking about ANSI color codes, but color using |
It works if you use Anyway, with the new wizard page of the installer that lets you choose the ConHost-based Git Bash, I consider this ticket to be addressed, because it was never about MinTTY per se, but always about having MinTTY as the only option for Git Bash. |
I heard no objections to my statement that this ticket is addressed by the new wizard page that let's the user choose whether to use MinTTY or ConHost for Git Bash. |
Current User, Current directory, git branch name are colored. |
@linquize probably yeah, any program that query console to know if it is interactive will get a non-interactive result and will usually disable colors. As a workaround, most program have a switch to force color. In those cases, I set up an alias. Otherwise, you need to use
For git, it works out of the box because git executable has been taught to determine if console is interactive using a different trick if it determines that execution is being performed on an MSYS2 base system. |
Playing around with the new development environment a bit, I found the following issues with mintty:
Issues with git / msys programs:
TERM=xterm
)Issues with other (native) console programs:
cmd /?
mangles äöü...)cmd /?
)The text was updated successfully, but these errors were encountered: