Skip to content
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

[BUG] Console(no_color=True) does not work on Windows 10 #2457

Closed
pirxthepilot opened this issue Aug 9, 2022 · 5 comments
Closed

[BUG] Console(no_color=True) does not work on Windows 10 #2457

pirxthepilot opened this issue Aug 9, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@pirxthepilot
Copy link

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:
richbug01

cmd.exe
richbug02

for reference, this is what it looks like from my Ubuntu laptop:

richbug-linux-ok

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. │
│ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ color_system = 'windows' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> │
│ height = 83 │
│ is_alt_screen = False │
│ is_dumb_terminal = False │
│ is_interactive = True │
│ is_jupyter = False │
│ is_terminal = True │
│ legacy_windows = True │
│ no_color = False │
│ options = ConsoleOptions( │
│ size=ConsoleDimensions(width=155, height=83), │
│ legacy_windows=True, │
│ min_width=1, │
│ max_width=155, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=83, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=155, height=83) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 155 │
└──────────────────────────────────────────────────────────────────────────────────┘
┌─── <class 'rich._windows.WindowsConsoleFeatures'> ────┐
│ Windows features available. │
│ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ └───────────────────────────────────────────────────┘ │
│ │
│ truecolor = False │
│ vt = False │
└───────────────────────────────────────────────────────┘
┌────── Environment Variables ───────┐
│ { │
│ 'TERM': 'cygwin', │
│ 'COLORTERM': None, │
│ 'CLICOLOR': None, │
│ 'NO_COLOR': None, │
│ 'TERM_PROGRAM': None, │
│ 'COLUMNS': '157', │
│ 'LINES': '83', │
│ 'JUPYTER_COLUMNS': None, │
│ 'JUPYTER_LINES': None, │
│ 'JPY_PARENT_PID': None, │
│ 'VSCODE_VERBOSE_LOGGING': None │
│ } │
└────────────────────────────────────┘
platform="Windows"

cmd.exe

┌───────────────────────── <class 'rich.console.Console'> ─────────────────────────┐ │ A high level console interface. │ │ │ │ ┌──────────────────────────────────────────────────────────────────────────────┐ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ │ │ │ │ color_system = 'windows' │ │ encoding = 'utf-8' │ │ file = <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> │ │ height = 30 │ │ is_alt_screen = False │ │ is_dumb_terminal = False │ │ is_interactive = True │ │ is_jupyter = False │ │ is_terminal = True │ │ legacy_windows = True │ │ no_color = False │ │ options = ConsoleOptions( │ │ size=ConsoleDimensions(width=119, height=30), │ │ legacy_windows=True, │ │ min_width=1, │ │ max_width=119, │ │ is_terminal=True, │ │ encoding='utf-8', │ │ max_height=30, │ │ justify=None, │ │ overflow=None, │ │ no_wrap=False, │ │ highlight=None, │ │ markup=None, │ │ height=None │ │ ) │ │ quiet = False │ │ record = False │ │ safe_box = True │ │ size = ConsoleDimensions(width=119, height=30) │ │ soft_wrap = False │ │ stderr = False │ │ style = None │ │ tab_size = 8 │ │ width = 119 │ └──────────────────────────────────────────────────────────────────────────────────┘ ┌─── <class 'rich._windows.WindowsConsoleFeatures'> ────┐ │ Windows features available. │ │ │ │ ┌───────────────────────────────────────────────────┐ │ │ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │ │ └───────────────────────────────────────────────────┘ │ │ │ │ truecolor = False │ │ vt = False │ └───────────────────────────────────────────────────────┘ ┌────── Environment Variables ───────┐ │ { │ │ 'TERM': None, │ │ 'COLORTERM': None, │ │ 'CLICOLOR': None, │ │ 'NO_COLOR': None, │ │ 'TERM_PROGRAM': None, │ │ 'COLUMNS': None, │ │ 'LINES': None, │ │ 'JUPYTER_COLUMNS': None, │ │ 'JUPYTER_LINES': None, │ │ 'JPY_PARENT_PID': None, │ │ 'VSCODE_VERBOSE_LOGGING': None │ │ } │ └────────────────────────────────────┘ platform="Windows"

rich==12.5.1

@pirxthepilot
Copy link
Author

Update: Seems to work if I explicitly set legacy_windows=False:

richbug-windows-legacy-false-ok

@willmcgugan willmcgugan added bug Something isn't working and removed Needs triage labels Aug 9, 2022
@darrenburns darrenburns self-assigned this Aug 9, 2022
@MarkZH
Copy link

MarkZH commented Aug 14, 2022

The bug also does not occur when running cmd.exe within windows terminal.

@darrenburns
Copy link
Member

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 #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 🙂

@github-actions
Copy link

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

@pirxthepilot
Copy link
Author

Thanks so much for fixing in a timely manner!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants