-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Using Windows Terminal with a git-for-windows tab displays odd characters #2483
Comments
|
@dscho As such I was offering up the example of the commands I run in arcanist which are attempting to use aspects of color and text formating that result in odd characters. As i listed in the other bug report with screen shots (and replicated here) I'm looking for help in addressing the way the odd characters appear in the msys/mingw/cygwin when it's used within Windows Terminal... perhaps this isn't an issue with git-for-windows then? Image of mingw in windows terminal with odd characters: Image of PS Core in windows terminal running same commands without odd characters: If this repo is also not the right place to list this bug advise and I'll keep looking for the right place. Thank you for your time. |
I'll need a minimal reproducer to assess (and possibly fix) the issue. Not screenshots. I will not install arcanist and hunt for that reproducer myself. |
Ok, this issue seems to consist of multiple layers.
Let me explain. You're probably using the recommended profile for Git Bash from the microsoft/terminal repo. That calls You're probably also using a PHP for windows, not msys2 or cygwin. That means arcanist disables ANSI color sequences if That leads arcanist to assume it can use ANSI color sequences, but your php doesn't know what to do with them. You could test |
@briannipper have you tried @rimrul's suggestion? What was the outcome? |
(as the Terminal maintainer, I'd be happy to learn that a bunch of our problems could be resolved by recommending something different.) |
@DHowett-MSFT I haven't checked: do you call |
My apologizes for the unusually long delay in following up on this. Thank you so much @rimrul you suggestion to use TERM=xterm FIXED all my formatting issues. Also, thank you for the additional explanation of the various layers involved, it's quite helpful to see the pieces as you outline them. After creating the entry in ~/.bashrc all my arc problems have disappeared. :) |
Our current recommendation is the former, but it looks like we're missing Thanks! |
Yep, without |
Perhaps it needs to be recompiled with a newer cygwin library as per microsoft/terminal#4809 (comment) |
The latest snapshot includes an MSYS2 runtime based on Cygwin v3.1.5, so it is safely newer than the suggested v3.1.2. Even Git for Windows v2.27.0 comes with an MSYS2 runtime based on a newer Cygwin (namely, v3.1.4): https://github.com/git-for-windows/build-extra/blob/cd17006382667f8bccd23060fa8610591c716709/versions/package-versions-2.27.0.txt#L110 |
@dscho just verified with https://gist.github.com/ketan/2866a236596636311d64 and I see the full color palette now for git bash. |
It might just be a question of setting |
I think it may be something that needs to happen in OpenJDK unless there's a per process handling. |
FWIW, here's a minimal example using git 2.29.2.windows.3 and Windows Terminal 1.7.1033.0:
Both |
@luismbo I just tried to your reproducer, and all the Git parts seem to work all right: But indeed, $ C:/Windows/system32/more "$(cygpath -aw /tmp/a1)"
←[31m←[1mRED←(B←[m However, at this stage I really have to ask: since neither Windows Terminal nor |
This one is interesting! If MSYS is using ConPTY and running |
@DHowett, @dscho I used |
Ah! We beat you by about two years; however, any application running inside Terminal is allowed to clear that flag if they want, and any sessions spawned by MSYS are sufficiently detached from the original hosting terminal that we can't know WT was involved to begin with 😄 (EDIT: However, this change is likely to have been released with Windows 11? I can figure out exactly when it came out ... but MSYS will be impacted by that pull request as well. 👍🏻) |
The plot thickens! I should be reunited with my Windows 11 machine some time next week, so I'll try that too. |
Thanks
|
Apologies for resurrecting an old thread, but... I seem to be running into something slightly similar to this with Git for Windows 2.35.1.windows.2. I have a console application running which emits ANSI colour codes. I'm running this inside the Windows Terminal. When I run it through a regular However, when executed via The Git Bash profile for Windows Terminal was added using the Git for Windows installer. The exact As can be seen above in the shell prompt etc, other ANSI colouring sequences are working perfectly. I also tested with the gist provided at https://gist.github.com/ketan/2866a236596636311d64, and all of this displays flawlessly as far as I can tell. I really don't know who to blame 😁 or where to start debugging this. Is this a problem with:
Any suggestions are greatly appreciated. 🙏 |
Did you try with |
@perlun @knutwannheden Have any of you gentle people tried the suggestion to set the environment variable |
@dscho Good point, worth trying. 👍 Here are the results.
|
I have another suggestion: can you run the |
FWIW, I have some more input using my minimal example using
|
Just in case using #include <stdio.h>
int main(int argc, char **argv)
{
if (argc != 2) { return -1; }
FILE *f = fopen(argv[1], "r");
if (f) {
char buf[512];
while (fgets(buf, sizeof buf, f))
puts(buf);
fclose(f);
}
return 0;
} |
Setting the // red.c
#include <stdio.h>
#include <windows.h>
int main(void)
{
HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode;
GetConsoleMode(con, &mode);
SetConsoleMode(con, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
puts("\e[31m\e[1mRED\e(B\e[m\n");
return 0;
} This This seems to suggest that Git's bash turns |
It's not really the Bash, it is the MSYS2 runtime, which is a close fork of the Cygwin runtime. Could you download the build artifact of https://github.com/git-for-windows/msys2-runtime/actions/runs/1961614385 (which essentially gives a preview of the changes that will come with Cygwin v3.3.5), extract the |
@dscho same behaviour.
|
I won't pretend to have time to dig into this deeper. There is a good chance, though, that this is actually an issue in Cygwin itself. If it is, you won't have to rely on me getting back to this issue, you can report it to the Cygwin project and have much better chances of seeing this resolved soon. |
Is there a workaround for this? |
Can you be more specific? |
FWIW, my problem described in #2483 (comment) is no loner present. The relevant versions:
I am unsure if this is because of a fix in either one of the above or changes in my own program, but I haven't done any changes that would have an obvious effect on this. (Such changes are being worked on, but they are not yet merged... 😉) |
Setup
defaults?
to the issue you're seeing?
https://secure.phabricator.com/book/phabricator/article/arcanist/
Details
Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
What did you expect to occur after running these commands?
What actually happened instead?
If the problem was occurring with a specific repository, can you provide the
URL to that repository to help us with testing?
arcanist with PHP in GitBash tab shows extra characters but not other tabs microsoft/terminal#4076 (comment)
The text was updated successfully, but these errors were encountered: