How do I always force `--console auto` in a gradle properties or environment variable?

For some reason, in gradle 2.7 my RoxTerm consoles are no longer using the rich output. The auto setting is not detecting that I can have a rich output.

I’d like to set this in a gradle.properties but I cannot figure out from the documentation how to actually do this.

How do I set a ~/.gradle/gradle.properties setting to always have --console=rich ?

AFAIK there’s not a way to force it via gradle.properties.

Did it stop working between Gradle versions (i.e., is it a bug on our side)?

What’s your environment? If you’re on a *nix, we look at the value for TERM and if it is set and not ‘dumb’, we then check if stdout/stderr are attached to terminals.

Actually it’s not even working in 2.1… Now I’m super confused… I remember it working in version 2.1, so maybe there’s an environment thing that happened… but I’m not sure what.

My environment:

Could you run with --debug to see if you see anything like this?

“Native-platform terminal integration is not available. Continuing with fallback.”

or

"Unable to load from native-platform backed ConsoleDetector. Continuing with fallback. Failure: {}

$ gradle --debug
22:29:00.107 [DEBUG] [org.gradle.internal.nativeintegration.services.NativeServices] Unable to load from native-platform backed Consol
eDetector. Continuing with fallback. Failure: net.rubygrapefruit.platform.NativeException: Failed to load native library ‘libnative-pl
atform-curses.so’ for Linux amd64.
caused by: java.lang.UnsatisfiedLinkError: /home/dkowis/.gradle/native/19/linux-amd64/libnative-platform-curses.so: libncurses.so.5: c
annot open shared object file: No such file or directory

Sure enough. I assume archlinux doesn’t have a libncurses.so.5

Yep, it’s got this:

$ pacman -Ql | grep libncurses.so
chef-dk /opt/chefdk/embedded/lib/libncurses.so
chef-dk /opt/chefdk/embedded/lib/libncurses.so.5
chef-dk /opt/chefdk/embedded/lib/libncurses.so.5.9
ncurses /usr/lib/libncurses.so

Obviously the chef-dk ones aren’t useful for you :smile:
So a workaround for me could be to make a symlink in /usr/lib to libncurses.so… But that isn’t actually necessary, because it works fine when I specify --console=rich

Hope all this helps.

Is something missing from your LD_LIBRARY_PATH or you’ve done a system upgrade recently? That might explain why it used to work. There might be a ncurses-5 package you could install.

It works when you use --console=rich because we forcibly use colors, even if we think the console doesn’t support them.

Ah yeah, a system update probably happened. Archlinux is a rolling distro.

core/ncurses 6.0-3 [installed]
System V Release 4.0 curses emulation library

So there is only one ncurses. I can workaround it by making a symlink in /usr/lib from ncurses.so.5 to ncurses.so and that will probably get the job done for now. Or I can alias gradle="gradle --console=rich "

Thanks!

No problem. This is the lib we use: https://github.com/adammurdoch/native-platform

It looks like there’s a TODO about failing more gracefully when ncurses can’t be loaded, which would probably handle your case.

I’ve stumbled over the same issue on archlinux. The latest update broke the console color support, yet it works with --console=rich.

For reference, as a temporary measure, until the library has better detection, you can do:

sudo ln -s /usr/lib/libncursesw.so.6.0 /usr/lib/libncurses.so.5

And then gradle properly picks up that it’s rich without having to type it every time.

Or do the shell alias :slight_smile:

As an FYI, arch linux has an ncurses5-compat-libs in the AUR that gives backwards-compatibility support.