-
Notifications
You must be signed in to change notification settings - Fork 855
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
ANSI colors no longer render in cmd.exe #1173
Comments
10.0.14393 is not the most current release. This should work totally fine in 14942 (latest). I think the processing used to be done in bash.exe. It has now been moved directly into conhost.exe as a console mode (enable rendering of terminal escape sequences) |
@fpqc https://support.microsoft.com/en-ca/help/12387/windows-10-update-history disagrees with your assertion. I tried Windows Update locally (Windows 10 Pro) and it says I have the latest version. I assume you're talking about an insider release? Also, did you actually try running my testcase in 14942? |
Yes it's talking about an insider release, and yes I've attempted it. I'm on 14936. 14942 just came out like an hour ago and I haven't had an opportunity to install it yet. Anyway, I suspect that the problem with Symfony is that the executable is not set to output to the command prompt in terminal-enabled mode. This is already documented in the posts about 24-bit color, linking to an msdn article iirc. Link the Symfony people to this article: https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx You need to enable terminal processing mode in the setconsolemode flags. I know that this documentation applies to the insider builds, not sure if it works in the official ones. |
@cowwoc For reporting bugs, you really need to be on the fast ring insider builds. The development here is done way faster than the Windows stable builds can keep up. |
Closing: 24-bit color color support was first introduced in Win10 Insiders Update 14931, and isn't available in the Win10 Anniversary Update. To exercise this feature, you'll need to join the Windows Insiders program and update your PC to install Fast-ring releases. Alternatively, you can opt for slow-ring updates and wait a few weeks for this feature to arrive. |
@cowwoc you have to set the console mode for printf.exe to enable virtual terminal processing, probably by recompiling it. GNUWin32 needs to be recompiled with this console setting enabled for each utility. It looks like the project is unmaintained. If it matters to you, fork the project, enable this mode as in the documentation (includes two examples), and you should be good to go. Is there any reason you need gnuwin32? Can't you use the cygwin versions? Another more recent project is this: https://github.com/bmatzelle/gow Last updated 8months ago vs 3 years ago. |
@fpqc I don't really care about printf. I was just using it because you were doing the same in your testcase. The only thing I care about is getting this to work with Java.
|
@cowwoc No idea, can you set console modes for java.exe? Request that Sun enables it in jvm? |
@fpqc There is no way to set console modes in Java without using JNI (which is not a realistic option for my use-case). It is also unlikely Sun/Oracle would enable this in the near future. I think it would help if someone from Microsoft address point 4: why were ANSI colors working in 10.0.10586 but got broken in version 10.0.14393? Something must have changed and I'm not convinced yet this was intentional. |
@cowwoc I dunno. I can't help you, and sorry, but the devs on this Issues page can't help you either. I know Rich Turner (Senior PM on the console enhancement project) has a special work-only Twitter account and maybe you can ask him why the default got changed (vis-a-vis escape sequence processing) and ask if there is a way to turn it on for a console java application. And if not, report it as a "bug" to Oracle and hope they fix it? |
@fpqc Perhaps @zadjii-msft could help? He is the one who marked #1173 as fixed. |
@cowwoc I dunno, Mr. Turner is kind of his boss, I think. I think you can turn it on maybe with an environment variable, can't you set those with Java? Edit: The solution suggested to setconsolemode on Windows for Java is to make a launcher wrapper that just does setconsolemode and then uses java.exe. |
@cowwoc Check out the top answer here: http://stackoverflow.com/questions/12404258/truly-interactive-command-line There is a project called Java Native Access (JNA) that lets you call SetConsoleMode from Java. It is currently maintained and will let you call SetConsoleMode in the Windows API. |
@fpqc JNA uses JNI under the hood, so this isn't an option. The only way to interact with native code is through JNI. |
@cowwoc I guess then you've gotta ask the Java people to set it or write a small wrapper program. I assume MS turned it off by default for a reason. |
@fpqc They simply mean that you don't need any extra JNI code. Quoting https://github.com/java-native-access/jna:
|
@cowwoc Yeah that's why I deleted my post. I continued reading it. What is this super-restrictive use case you have with no JNI at all? Maybe you can be a hero and write a generic mini-loader for Java, then throw it up on github? |
@bitcrazed Seeing as you closed this issue, can you please clarify why ANSI colors were working in 10.0.10586 but no longer work in 10.0.14393? @fpqc It's a long story, but the jist of it is that JNI is a deployment nightmare. You have to deploy different JAR files for different platforms. On platforms that use native code, you have to unpack the libraries before loading them. Maven (the prominent build system for Java) handles building and packaging native libraries very poorly. And so on... The minute I introduce native code to my library I am pushing this complexity on users of my library (and their users, transitively). Considering what my library does (https://bitbucket.org/cowwoc/requirements/) this would be a major deterrent to its use. I seriously hope there is a way to use this functionality without invoking |
@cowwoc Isn't that the point of JNA, no need to extract all those native libraries? You just have the single dll, and that lets you make calls to the Windows API, just a single quick branch on initialization? |
@fpqc I appreciate you trying to help, but whether it's one DLL or many, you still end up with the deployment problems I mentioned. |
Is the problem still appearing if you use ConEmu?
https://conemu.github.io
|
@Manouchehri That's not the problem, he wants his java application to run on unpatched Windows conhost in stock configuration and default settings with color-escape sequence processing enabled. Apparently this was changed from the default in Anniversary update, and he lost compatibility. |
@Manouchehri As fpqc mentioned, this works in conemu, but I want to get my Java application to output ANSI colors on an unpatched Windows conhost using the default configuration. |
@Manouchehri It depends on the console application. Bash has that mode set, but Java doesnt. |
Oh my, you leave the office for one weekend, and this happens :P There's a lot going on in here, so let me try to clarify: The windows console only supports VT sequences of ANY kind with the By default,
To further confuse, I can't really speak about the Java issue at hand, it's been far too long since I've used Java, and I don't really have any experience calling Win32 API's from java. I did end up writing a snippet of code that enables VT support on Windows in python, so it can be done. In conclusion: I'm going to leave this issue closed, as this is the proper, expected behavior. Confusing, but correct. Also, in terms of hierarchy, @bitcrazed is the PM for the console, while I'm one of the devs |
Having this issue on the latest Windows 10 Creators. Was working fine (for all my Minecraft Servers) now, the MC servers will error out with after my PC installed the Creators update. Question: Is microsoft simply trying to interfere with people that script out their windows to run commercial systems and services? By doing something as simple as not including the flag/ability in new releases they effectively break all sorts of services people may have deployed at every update, no doubt, because it's not their Server editions.
|
@WASasquatch The error you pasted has nothing to do with Windows. Please google |
Same issue with just printing color codes via any program via bash. I was using this as a program-breaking example. |
@WASasquatch Can you reproduce this issue without using jansi? If so, can you provide a testcase others can run? |
@WASasquatch That definitely looks like a java problem, not a conhost or WSL problem to me. Do you have a specific, simple example of VT sequences not working in WSL? They're a pretty heavily tested part of the system, I doubt they would have broken: |
As noted here and here, the ANSI VT can be enabled for SetConsoleMode-oblivious apps, without having to re-compile them, by changing the following registry key.
This changes the system-wide default for ANSI VT processing from opt-in to opt-out, so it will affect any/all apps that don't express a preference. Works for Windows 10.16257 (and later) (and possibly earlier). Given the very helpful information in a comment on this page by @zadjii-msft, this registry setting would appear to be the only workaround for apps that can't be re-compiled to include a call to |
Can this be understood as the setting overriding any I'm asking because I get very funny results running on W8.1 where reading the |
The v1 console (the only version of the console available on pre-Windows 10) probably doesn't ignore flags that it doesn't support, so you could probably SetConsoleMode with Edit: To add, |
Just a note to anybody using Python. You can enable ANSI using this:
|
jna is ok too |
Use this to enable terminal colors by updating the registry using Java :
|
Please use the following bug reporting template to help produce actionable and reproducible issues. Please try to ensure that the reproduction is minimal so that the team can go through more bugs!
Color rendering issues #76 and support 256 color #345 added support for ANSI colors. This works in version 10.0.10586 but got broken in version 10.0.14393.
symfony/symfony#19520 confirms that other people are seeing the same problem.
ANSI colors should render in cmd.exe when applications output to stdout/stderr.
Raw ANSI codes are seen. No colors are rendered.
10.0.14393
�[37;1mwhite�[0m
foo.log
and runtype foo.log
white
using white textThis is reproducible 100% of the time.
The text was updated successfully, but these errors were encountered: