fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.11k stars 140 forks source link

Jansi fails to start on Mac arm #207

Closed michaelabuckley closed 3 years ago

michaelabuckley commented 3 years ago

No native code included for arm. macOS 11.2.3 Apple M1 Jansi 2.3.2

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.fusesource.jansi.AnsiConsole.ansiStream(AnsiConsole.java:239)
    at org.fusesource.jansi.AnsiConsole.initStreams(AnsiConsole.java:542)
    at org.fusesource.jansi.AnsiConsole.systemInstall(AnsiConsole.java:496)
    at ca.cdr.app.control.ControlClient.<init>(ControlClient.java:54)
    at ca.cdr.app.App.main(App.java:201)
Caused by: java.lang.RuntimeException: Unable to load jansi native library
    at org.fusesource.jansi.internal.JansiLoader.initialize(JansiLoader.java:62)
    at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:30)
    ... 5 more
Caused by: java.lang.Exception: No native library found for os.name=Mac, os.arch=aarch64, paths=[/Users/michael/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
    at org.fusesource.jansi.internal.JansiLoader.loadJansiNativeLibrary(JansiLoader.java:333)
    at org.fusesource.jansi.internal.JansiLoader.initialize(JansiLoader.java:60)
    ... 6 more

Output of uname -a

Darwin mb-m1 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
rfscholte commented 3 years ago

This issue is blocking https://issues.apache.org/jira/browse/MNG-7165 (and considered a regression). Looking at the comment of the try/catch block of https://github.com/fusesource/jansi/blob/jansi-2.3.2/src/main/java/org/fusesource/jansi/AnsiConsole.java#L239-L250 the fd initialization should be done inside the try-block.

michaelabuckley commented 3 years ago

@rfscholte - I just did the dumb thing

try {
    AnsiConsole.systemInstall();
} catch (Error e) {
   // log some stuff
}
rfscholte commented 3 years ago

I don't think that will work in our case, The library maven-shared-utils is used by both Maven and maven-plugins, they can all have their own version. JAnsi is bundled with Maven, so we could fix it for Maven, but not for the plugins.

michaelabuckley commented 3 years ago

FYI - https://github.com/java-native-access/jna supports Mac ARM now. That might be easier that shipping your own dlls.