-
Notifications
You must be signed in to change notification settings - Fork 619
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
Colors not working in Powershell env #169
Comments
Are you sure that it is a problem with this library? I am working on Windows and never encountered any problems. I am using this library in https://github.com/goyek/x and I have encountered no issues. Maybe some accurate repro steps? 😉 |
I reproduced this problem when So probably the problem is that it is PowerShell inside conhost. Can you confirm? Maybe it is a problem in "PowerShell coloring" design? |
It is my understanding that for Windows to properly work with ansi code colors, the application need to signal color awareness thru api:s. If not, color support might be randomly broken between different shells. fatih/color does not do this setup on Windows, resulting in the same app looking fine in the Powershell Shell or Windows Terminal because they do this setup for every process, but ansi escape sequences are printed while in msys-bash (alongside other apps that properly outputs color by opting in). The essence of the issue is that in Windows 10 an application need to "opt in" for ansi code support by calling SetConsoleMode() with the ENABLE_VIRTUAL_TERMINAL_PROCESSING bit set. Here is a better explanation than mine: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#output-sequences I write all of this by experience from previously debugging a similar issue in a rust crate |
Sent a PR which fixes the issue on my end. |
@GiulianoDecesares this issue is still open, the PR #173 is not merged. It seems that I accidentally closed the PR, i have reopened it now. |
@GiulianoDecesares can you try out @martinlindhe's fix here #173 ? |
Yes, Is there any practical way to test this or I just have to download the entire repository and manually replace the references in my code? (I don't know, maybe I can |
@GiulianoDecesares I would try running |
@pellared yep! Already tried, but go takes |
Then probably the easiest way is to
|
Thanks @pellared for the info on the |
windows: enable virtual terminal processing, fixes #169
The fix is now released with |
Using the Cluster API CLI clusterctl prints the output with color on linux and mac environments, but the same does not work for Windows PowerShell and cmd. The output includes the Raw ANSI codes instead making it unreadable. The current workaround is to set the
NO_COLOR
env variable to turn off color completely, resulting in a readable, but colorless output.Is there a way to configure the library to get the correctly colored output on Windows environments?
Related issue: kubernetes-sigs/cluster-api#7381
The text was updated successfully, but these errors were encountered: