-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Bright console colors don't work correctly on Linux #23241
Comments
That powershell prompt looks pretty slick....! |
@bradwilson, what is the value of your TERM environment variable? Is it "xterm"? What happens if you do |
TERM is one thing to look for. The colors also possibly depend on profile and termcap/terminfo |
@stephentoub That's worse, actually: Neither of my failure cases (SSH or native console) have FWIW, I don't believe that |
@wfurt The Is .NET Core's color implementation not depending on the bold terminal feature? |
can you please describe what system you are connecting to and how? What I was trying to say is that terminal handling (and colors) are somewhat more complicated. The are parts is profile setting. Many distributions try to do all kinds of fancy stuff. The other part of the puzzle may also be output setting. For example, in some cases you would get colors from 'ls'. But you would not if you pipe that to for example 'less' or 'more'. If I have more details I'll try to repeat than and reproduce behavior you observed. |
As described above, this is an Ubuntu Server 16.04 VM, running on Hyper-V. I experience the issue both via SSH (using the ssh client from Git for Windows) as well as via the native Linux console for the server (accessed via Hyper-V's client). TERM for SSH = |
It is, but whether that's supported is dictated by the terminal, and what the terminal supports is exposed via terminfo, which .NET Core examines to determine what it can do. The terminfo specifies the max number of colors supported, and that's taken into account here when Console writes out the relevant escape string: |
@stephentoub It says 8 colors with bold, as I would've expected. It would appear that you're not checking for bold support to see if it's available and just assume that 8 is all you can do (rather than bolding the 8 for 16).
|
My ubuntu also supports "dim" (half-bright) |
@bradwilson, are you referring to the entry |
I'm suggesting that in the face of 8-color + bold, you can at least get the 16 foreground colors (if not the 16 background colors). |
FWIW, while I think it would be beneficial to the community at large to fix this, the fact that it's broken (and unlikely to be fixed) in 1.x as well as 2.x means that I'll probably leave my ANSI version in indefinitely. I can't imagine this would reach the bar of fixing it in LTS. |
few articles for reference https://askubuntu.com/questions/875102/gnome-terminal-use-bright-colors-for-bold There seems to be general debate if bold/bright shall be used as extra colors. |
Yeah, that's why we only consider the color count. But I think it'd be reasonable to augment the code to also consider bold for foreground in the case of 8 colors and bold supported. |
I did some testing with this and I don't think it going to work as proposed. I can also change iTerm2 properties and map color/bold sequences to any color I choose. This setting also has no impact on background colors. |
|
@david-tamar if you have idea how to fix it, we would welcome a contribution. Otherwise I am afraid this is not too high on our priority list. |
I'm working right now on a solution using ANSI escape codes and testing it, but I'm going to use 256 colors, so my solution is incompatible with the Windows command prompt (I'm also not sure whether it interprets ANSI escape codes properly). |
I'm not sure there is good general fix. Time of monochromatic terminals is long gone. Getting more colors is easy as setting environment variable. |
I just wanted to note that if anyone still needs proper support for True Color (24-bit), 256-colors (8-bit), or just the usual 16 (4-bit) colors and ANSI escape codes (bold/italic/underlined text etc) on terminals that support it on Linux/POSIX, then I have re-implemented the |
Triage: we welcome contributions towards improving this. |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
Given the following C# code:
When run on Windows 10, it correctly prints out with bright foreground and background colors:
When run on Linux (in my example, Ubuntu Server 16.04), bright colors are shown dark:
I verified this with bug .NET Core 1.x and 2.0. The reason this came up is because I noticed that the color output from
dotnet xunit
was broken, as we rely on bright colors when writing our output. I have a temporary workaround in place which emits the correct ANSI codes when running on non-Windows machines. Here you can see the difference between the Windows and Linux outputs:As an interesting postscript, the bug does not seem to affect Windows Subsystem for Linux:
So when verifying this bug, it's important to use a real Linux installation (I used VMs in Hyper-V for my testing).
/tag @karelz @terrajobst
The text was updated successfully, but these errors were encountered: