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 2.0.1 error: Unable to load jansi native library: java.lang.Exception: No native library found #181

Closed remkop closed 3 years ago

remkop commented 3 years ago

When I upgrade the picocli dependency on Jansi from 1.18 to 2.0.1, I see the following error on my Travis CI server:

For example, in this Java 8 build, I see this in the build log:

  • Where: Build file '/home/travis/build/remkop/picocli/build.gradle' line: 98
  • What went wrong: A problem occurred evaluating root project 'picocli'.

    Supplied String module notation 'org.fusesource.jansi:jansi:2.0.1 # Unable to load jansi native library: java.lang.Exception: No native library found for os.name=Windows, os.arch=x86_64, paths=[/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]' is invalid.

... Caused by: org.gradle.api.IllegalDependencyNotation: Supplied String module notation 'org.fusesource.jansi:jansi:2.0.1 # Unable to load jansi native library: java.lang.Exception: No native library found for os.name=Windows, os.arch=x86_64, paths=[/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]' is invalid. Example notations: 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'. at org.gradle.api.internal.artifacts.dsl.ParsedModuleStringNotation.assignValuesFromModuleNotation(ParsedModuleStringNotation.java:47)

I see identical errors in the picocli build log for other JDK versions (9-15).

The line causing the error in build.gradle is where the test dependencies are declared:

    dependencies {
        testImplementation "junit:junit:$junitVersion",  // <-- this is line 98
                           "org.hamcrest:hamcrest-core:$hamcrestCoreVersion",
                           "org.fusesource.jansi:jansi:$jansiVersion",
                           "org.codehaus.groovy:groovy-all:$groovyVersion",
                           "com.github.stefanbirkner:system-rules:$systemRulesVersion",
                           "pl.pragmatists:JUnitParams:1.1.1"
    }

Any idea what could be causing this?

gnodet commented 3 years ago

@remkop do you embed Jansi somehow ? The path to the native libraries in the jar has changed between 1.x and 2.x, so if you do anything fancy with the native libraries in Jansi, it may have been broken.

remkop commented 3 years ago

The problem disappeared when I upgraded to Jansi 2.1.0, so that's good. Also indicates it wasn't anything in picocli. :-)

remkop commented 3 years ago

I'm happy to close this ticket.

ilatypov commented 2 years ago

Since this issue pops up searching "gradle exception jansi" due to poor packaging (as in Debian sid with bug 921993) or a protective system environment (as in GRADLE-3573), I found that isolating the consuming application with nohup in Linux or using the application-specific option (gradle --console=plain) avoids using jansi.