rich
rich copied to clipboard
[BUG] Console(no_color=True) does not work on Windows 10
You may find a solution to your problem in the docs or issues.
Describe the bug
The "no_color=True" Console parameter does not seem to do anything on Windows 10. I tested on both Cmder and native cmd.exe terminals and got the same results. See screenshots below.
Cmder:
cmd.exe
for reference, this is what it looks like from my Ubuntu laptop:

Also happy to help fix this if you can point me in the right direction. Thank you!
Platform
Click to expand
OS: Windows 10
Cmder:
┌───────────────────────── <class 'rich.console.Console'> ─────────────────────────┐
│ A high level console interface. │
│ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ <console width=155 ColorSystem.WINDOWS> │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ color_system = 'windows' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='
cmd.exe
┌───────────────────────── <class 'rich.console.Console'> ─────────────────────────┐ │ A high level console interface. │ │ │ │ ┌──────────────────────────────────────────────────────────────────────────────┐ │ │ │ <console width=119 ColorSystem.WINDOWS> │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ │ │ │ │ color_system = 'windows' │ │ encoding = 'utf-8' │ │ file = <_io.TextIOWrapper name='
rich==12.5.1
Update: Seems to work if I explicitly set legacy_windows=False:

The bug also does not occur when running cmd.exe within windows terminal.
It was an issue with rendering on "legacy" terminals on Windows, so would only affect people using older versions of cmd.
In legacy rendering, Rich calls Win32 APIs directly, rather than using the same codepath as on Linux/MacOS. Turns out that code didn't consider no_color at all!
Fixed as part of https://github.com/Textualize/rich/pull/2458, so this should be resolved in the next release of Rich. Keep an eye out for the next release and let us know if you hit any further issues with it 🙂
Thanks so much for fixing in a timely manner!