question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enable `--ansi` by default on Windows

See original GitHub issue
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

The --ansi option should be default on Windows.

On a fresh install of Windows 10 with a fresh install of the Windows version of Python 3.9.0 Install Poetry via:

py -m pip install --user pipx
py -m pipx ensurepath
# need to get a new console now for pipx to be on PATH
pipx install poetry

Now in both PowerShell and in cmd.exe running pipx --ansi produces nice colors.

Is there a reason not to default --ansi on Windows?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
TBBlecommented, Aug 13, 2021

I also see Poetry 1.2.0a2 failing to auto-detect ANSI support:

  • Windows Terminal Preview 1.10.1933.0
  • PowerShell 7.1.3
  • Python 3.9.6
  • pipx 0.16.4

image

image

The ANSICON env-var workaround still successfully enables ANSI.

image

(Ignore the warning about Poetry already existing, that’s noticing my Poetry 1.1.7 installation)

I also checked pipx run --spec poetry==1.2.0a1 poetry just in case it was working in a1 but broken in a2, but the result was the same.

I just checked, and the faulty code that was in clickit (see https://github.com/sdispater/clikit/issues/35#issuecomment-751977044) is still unchanged in cleo 1.0.0a4, so the bug is still in the underlying library: Cleo only auto-detects ANSI for Windows if it can turn on ENABLE_VIRTUAL_TERMINAL_PROCESSING, but not if it is already turned on, as is the case for Windows Terminal or other ConPTY-supporting terminal emulators.

I raised a new issue at https://github.com/sdispater/cleo/issues/104

2reactions
Jhraumgcommented, May 23, 2021

I could reproduce it from my Windows Terminal + git bash and poetry 1.1.6 (while it worked flawlessly with the same git bash and cmder)

With poetry version 1.2.0a1, it seems all fixed (thanks to #3618 I guess):

  • poetry displays color automaticaly on Windows Terminal
  • poetry does accept global parameter before command (which could help aliasing poetry to poetry --ansi, but it is non necessary anyway 😉 )
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use ANSI colors in the terminal - Windows CMD - SS64.com
To use ANSI colours in the Windows terminal requires setting VirtualTerminalLevel. VirtualTerminalLevel = 1 is now set by default for the terminal and...
Read more >
How to make win32 console recognize ANSI/VT100 escape ...
FYI, in latest Windows 10, you can enable ANSI in conhost via the following reghack -- in HKCU\Console create a DWORD named VirtualTerminalLevel ......
Read more >
Windows 10 1903) How to change Default Encoding UTF-8 to ...
In Regedit go to Computer\HKEY_CURRENT_USER\Software\Microsoft\Notepad. - in the menu select edit/new/DWORD.
Read more >
Enable ANSI escape sequence within Windows 10 console
The registry key at HKEY_CURRENT_USER\Console\VirtualTerminalLevel sets the global default behavior for processing ANSI escape sequences. Create ...
Read more >
Enable ANSI colors in Windows command prompt - Liferay
Windows command prompt by default does not have this feature. But do you remeber ANSI.SYS driver for DOS that enables this? I hope...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found