deno: Coloring with escape sequences doesn't work on Windows
On Windows, escape sequences don’t color Deno’s output and display as ordinary text.
For example, an error stack trace looks like:
Uncaught SyntaxError: Unexpected string
at ←[1m←[3m←[90mevaluate←[39m←[23m←[22m←[90m(←[39m←[90m$deno$/repl.ts←[39m←[90m:←[39m←[90m45←[39m←[90m:←[39m←[90m34←[39m←[90m)←[39m
at ←[1m←[3m←[90mObject.replLoop←[39m←[23m←[22m←[90m(←[39m←[90m$deno$/repl.ts←[39m←[90m:←[39m←[90m136←[39m←[90m:←[39m←[90m13←[39m←[90m)←[39m
I hope that this can be fixed.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 38 (10 by maintainers)
I’d give them all the same advice, which is to avoid using inferior software when something better is readily available (which is exactly why people are interested in Deno over Node), but I understand your point.
@cj81499 I could use a different terminal, of course, but Deno also could be fixed, if it’s possible to fix. That’s why I reported this issue here.
Also, it isn’t just about me, but everybody who wants to use Deno with
cmd.exefor some reason. If I just moved on to a different terminal, then the next one of them would have opened this issue…Windows 8.1 isn’t however.
The problem is not “pretty output” though, output is gibberish right now as it contains control characters. The example provided here show how illegible the whole thing is.
I tried this (Windows 8.1 too), it works for PowerShell when ran as a stand alone program. When ran as embedded in VS Code all the escape sequences keep being displayed as text (just like in the original report). I tried configuring VS Code to launch an external terminal instead of an embedded one and also tried changing the render type of the terminal (auto, canvas, dom, experimentalWebgl) but nothing helped.
@always90s, they are. On Windows 8 the only way to get support for it is to install PowerShell 5.
I’d like to second @fzs111’s concern.
The issue is not limited to Windows 10’s legacy mode but also appears on earlier Windows versions with, both, the standard command prompt and PowerShell.
@fzs111 seems like you could just use a different terminal, such as Powershell or Windows Terminal.
The whole subject is not really about colours or not colours.
Standard output on pre-Windows 10 is broken altogether and only produces gibberish.
That is clear, hence my question if Windows 8 is a supported platform or not.
It is I am afraid. As I addressed earlier, if it is a support platform reported bugs should be acknowledged and fixed. If it is not supported, obviously not but that should be communicated.
Again, no offence but these standard phrases are not very helpful.
As far as I am aware, Node does not ship with a “color this string for terminal output” function. The goto package here is
chalk. chalk does not call Windows Console APIs, but uses escape sequences, too.chalk does have detailed checks for whether colors are supported, though:
https://github.com/chalk/supports-color/blob/master/index.js#L70-L71
I think the “are colors supported?” checks are a good idea and something that we can add to Deno.
Personally, I think it’s not worth the trouble to implement the Windows Console APIs for color support on older systems, such as, old Windows 10 builds (we’re at 19041 now, first build with color support is 10586), Windows 8.1, 8, 7, Windows Vista, XP, etc.
Recent Windows 10 builds seems like a reasonable target to me.
That might be true, but a bug in a module does not mean it should be equally buggy everywhere else. Colour sequences are not supported on all systems and Windows is one of them.
If there is no plan to address that, then the consequence should be to officialy drop support for pre-10 versions respectively for the traditional command prompt.
I ran the following command in my windows powershell window
Do I need to downgrade to powershell 5 instead of 5.1?
Have you tried using the standard library?
Whenever a hipster software does stuff like unasked and unsuccessful printing colors to my cmd.exe, I temporarily use a console wrapper called cmder, which has other bugs, but hides these ‘←[33m’ thingies.
Of course, it would be better if software would behave more conservative regarding default console windows in second most used operating systems in the world.
Edit: I just learned, by typing
deno helpthat an environment variableNO_COLOR=truewill disable this. I take back the ‘hipster’ comment.Edit 2: I have created a SO self answer pointing to the environment variable or console emulators.
I found a workaround, get ANSICON. Install following the instructions in the readme.txt. If you want this just for VS Code instead of a global installation you can use the following settings:
I know, but if you don’t have a capable terminal emulator that’s pretty much expected. Not that many people bother with non vt100 capable terminal emulators. Most of cli’s available via npm rely heavily on it.
Really just boils down to if we want to support curses/conio-esque syscalls in the Deno namespace.
As mentioned by @neroux & @fzs111 this isn’t about “pretty output”, it’s about usable output. In Windows 8.1 this is the type of output received whether using
cmd.exeor PowerShell (versions 4, 5.1, 7.02, 7.03 or 7.1.0):@caspervonb And, this isn’t just about pretty output (that one could turn off without consequences with a simple
NO_COLOR=1env variable – though it disables colors in all other console applications too), but all escape sequences, including e.g. cursor control, without which many interactive and some non-interactive CLI apps break.I don’t know whether it’s supported or not. I haven’t seen any official statements about Windows support in the docs.
I’m merely pointing out that Windows has a different support lifecycle than Deno. Just because some old Windows version is still supported by Microsoft, doesn’t mean Deno has to support it, too.
Also, as I have pointed out, “support” is a spectrum of various degrees. Deno can support Windows 8.1, but not support properly colored output in
cmd.exe. Those are not contrary positions.Deno is an open source project. Feel free to send a PR.
So Windows 8.1 is not a supported platform by Deno?
No offence, but that remark is somewhat pointless 😉
I never said Windows colours should be supported. Simply disable the colour sequences on platforms which do not support it and we are good.
Windows extended support != Deno support.
AFAIK,
deno eval -p "'Hello, world!'"works fine, even without colors. Even better, bothstd/fmt/colorsandcli/js/colorsrespectNO_COLORsoset NO_COLOR=1& deno eval -p "(await import('https://deno.land/std@v0.60.0/fmt/colors.ts')).red('Hello, world!')"works just fine, too.I agree that
Deno.noColorcould automatically determine that colors are not supported on older Windows builds to disable colored formatting on such systems. That’s a simple, unintrusive fix. But implementing complicated Windows Console APIs for systems that are gonna be off extended support soon seems just plain unnecessary to me.Exactly what I said, it is a supported system and if it is supported by Deno, bug reports should be adequately received and fixed.
It pretty much is. Right now its output is useless. It also is not “some terminals” but the basic system terminals. As I said before, it is pretty easy. Either fix the issue or mark everything before 10 as unsupported.
Windows 8.1 is from 2013. End of mainstream support was 2018. End of extended support is 2023. Again, I don’t think it’s worth it to invest too much time into supporting those older systems.
Just because colors are incorrectly displayed in some terminals, doesn’t mean it’s “imcompatible”.
Well, everything before 8.1 is not supported anymore anyhow, so it is not unreasonable to say Deno doesn’t support it either. 8.1 however still is supported.
Then mark Deno as incompatible with Windows 8, respectively clearly state only Windows 10 is a supported platform, and you are good to go.
As it is right now the output on Windows 8 is pretty useless.
That would be preferable of course.
@caspervonb, as for “abandoning legacy systems”, yes it is accurate that Microsoft is moving towards a more Unices-like formatting here, however Windows 8 doesn’t support colour sequences at all and even Windows 10 doesn’t fully support them.
Considering that Windows 8 is still a support system, which also seems to be supported by Deno, it is fair to call this a bug.
I’m getting the following results after installing Deno on my Windows 8 machine. I ran the following command from windows powershell and from vscode terminal. Seems like the escape characters are always showing up.