-
Notifications
You must be signed in to change notification settings - Fork 132
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
Colour output doesn't work in cmd on Windows #749
Comments
I probably should have mentioned, this isn't true for all commands. The |
Oh, that's funny then - if all color was wrong then we'd know that there's something wrong with the lway we do logging, but if only some coloring is wrong then I am not really sure how to even debug this. Do you have any ideas? We're using the logging machinery from |
Ah! I think it's something that
So before the compiler is invoked: no colour, after, colour. |
I have an idea of something to try 🙂 |
Oh I see, that makes sense. Note that we just disable ANSI codes when Lines 24 to 27 in 72315e0
..but maybe we should just disable it when running on Windows at all? |
Yeah would nice to get this fixed. I've tried to do some investigating but it's quite laborious with the little knowledge I have. I've found though that if you just open start a stack repl in the Spago folder, and then do Also about |
I've not yet managed to determine what the difference is between I was looking into how stdio was configured with utf-8 support, etc. to see if there was something there as it seems like it must be something along those lines, but I've not gotten back to it to try again yet. I'm probably going to try in a fresh CLI app entirely and see if it works "out of the box", and if not, I can maybe figure something out in there then take it back to |
Yeah that was just what I was trying next, just with |
Interesting! When I hacked spago to the point of printing a colour-coded line from its |
Ok no I have to correct that. It's when running the exe through |
Could it be because the compiler calls |
Replicating the IO setup there was the first thing I tried when I hacked my local |
That didn't work but I think it lead me to the right answer :) Just preparing a PR... |
Calling the `hSupportsANSIWithoutEmulation` function on Windows 10+ enables terminal colors where supported. https://hackage.haskell.org/package/ansi-terminal-0.11/docs/System-Console-ANSI.html#v:hSupportsANSIWithoutEmulation Also has the added benefit that (on Windows), the ANSI codes aren't present when output is redirected to a text file.
Calling the `hSupportsANSIWithoutEmulation` function on Windows 10+ enables terminal colors where supported. https://hackage.haskell.org/package/ansi-terminal-0.11/docs/System-Console-ANSI.html#v:hSupportsANSIWithoutEmulation Also has the added benefit that (on Windows), the ANSI codes aren't present when output is redirected to a text file.
Fixes colors on Windows (#749), by calling the `hSupportsANSIWithoutEmulation` function, which enables terminal colors on Windows 10+ (https://hackage.haskell.org/package/ansi-terminal-0.11/docs/System-Console-ANSI.html#v:hSupportsANSIWithoutEmulation) Additionally, using this function in the way we do here means colors are automatically disabled when output is redirected to a file. Test fixtures are modified to reflect this. `hSupportsANSIWithoutEmulation` should also check for the `TERM=dumb` environment variable, but it doesn't on Windows, and on *nix this hasn't been tested, so the existing code here that does this check has been left in for now. Finally, support is added for the https://no-color.org spec with a simple check for a `NO_COLOR` environment variable.
Oh I thought this would be closed when #768 was merged. I guess because I only mentioned the issue in the commit message body and not the first line. Anyway, closing now |
It just prints the colour codes as text:
Perhaps related to #729, but the suggestion there is there's a regression in an upstream library, and it's been this way for as long as I've been using spago. That doesn't necessarily rule out the upstream regression, as I came to it late!
The text was updated successfully, but these errors were encountered: