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 Not Executable In '/tmp' on CENTOS #241

Closed clementmark closed 1 year ago

clementmark commented 2 years ago

Hi All

Wondering if anyone else has experienced a similar issue. I have recently upgraded to JDK 8 and Maven 3.8.5 and when i try mvn --version i get an error as such:

Failed to load native library:jansi-2.4.0-bbb285ac9ffab828-libjansi.so. The native library file at /tmp/jansi-2.4.0-bbb285ac9ffab828-libjansi.so is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location. osinfo: Linux/x86_64 java.lang.UnsatisfiedLinkError: /tmp/jansi-2.4.0-bbb285ac9ffab828-libjansi.so: /tmp/jansi-2.4.0-bbb285ac9ffab828-libjansi.so: failed to map segment from shared object: Operation not permitted Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0) Maven home: /opt/apache-maven-3.8.5 Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: /opt/jdk1.8.0_251/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-1160.49.1.el7.x86_64", arch: "amd64", family: "unix"

java version "1.8.0_251" Java(TM) SE Runtime Environment (build 1.8.0_251-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)

I have also tried installing JANSI through yum and that does not seem to resolve it. sudo yum -y install jansi-native

Any help or guidance on how to resolve this would be greatly appreciated.

CentOS Linux release 7.9.2009 (Core)

apache-maven-3.8.5

jdk1.8.0_251

clementmark commented 2 years ago

The default installation on CENTOS marks the '/tmp' as nonexec. For security reasons it is not viable to remount '/tmp' as exec. Could this directory be parameterised?

michael-o commented 2 years ago

Oh c'mon, really? I asked you to raise an issue to properly document loading algorithm and not to complain that you have mounted /tmp with noexec. I have provided a proper solution for your problem.

michael-o commented 2 years ago

The default installation on CENTOS marks the '/tmp' as nonexec.

This is not true. I have recently installed CentOS 7 and it is not mounted with that option.

Could this directory be parameterised?

Did you actually read my long description what you can do?

michael-o commented 2 years ago

Reference: https://issues.apache.org/jira/browse/MNG-7485

clementmark commented 2 years ago

Hi Michael,

Thanks for your response albeit non professional. We have had our DevOps team and Security team stating that remounting '/tmp' as exec is a no go for us just to use the latest maven version.

There have been further responses stating the same. I would not advise this either to other people having the same issue.

We have reverted back to using Maven 3.5.0 until this is addressed.

Thanks for your response. (End of conversation)

flopma commented 2 years ago

Hello all,

We have 40 CICD servers using Maven v3.8.6 where JANSI 2.4.0 is used. When our CICD server (Atlassian Bamboo) executes tasks with Maven, it always execute mvn with the parameter -Djava.io.tmpdir=/somecustompath and this path is on a mount point with parameters rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota

However, when maven executes, it shows he warning Failed to load native library:jansi-2.4.0-ead001ff715b1196-libjansi.so. The native library file at /tmp/jansi-2.4.0-ead001ff715b1196-libjansi.so is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location. osinfo: Linux/x86_64

But I don't understand, because line 80 in https://github.com/fusesource/jansi/blob/jansi-2.4.0/src/main/java/org/fusesource/jansi/internal/JansiLoader.java#L80 shows that default folder would fallback on java.io.tmpdir, but it seems it doesn't.

Do you have an idea why this is happening?

Thank you

flopma commented 1 year ago

Hello @gnodet , can you have a look at this please? I ran Maven with some logs and it shows that Maven is called with the parameter java.io.tmpdir. I don't understand why jansi is not making use of it. Do you have an idea?

simple 09-Sep-2022 11:31:09 Starting task 'Maven 3.x' of type 'com.atlassian.bamboo.plugins.maven:task.builder.mvn3' command 09-Sep-2022 11:31:09 Beginning to execute external process for build 'PROJ - tt - Default Job #37 (PROJ-TT-JOB1-37)'\n ... running command line: \n/opt/myproject/commons/maven-3.8.6/bin/mvn --batch-mode -Djava.io.tmpdir=/opt/myproject/tmp/PROJ-TT-JOB1 compile dependency:resolve enforcer:enforce\n ... in: /opt/myproject/bamboo-agent-home/xml-data/build-dir/PROJ-TT-JOB1\n error 09-Sep-2022 11:31:10 Failed to load native library:jansi-2.4.0-18397875f260a08e-libjansi.so. The native library file at /tmp/jansi-2.4.0-18397875f260a08e-libjansi.so is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location. osinfo: Linux/x86_64 error 09-Sep-2022 11:31:10 java.lang.UnsatisfiedLinkError: /tmp/jansi-2.4.0-18397875f260a08e-libjansi.so: /tmp/jansi-2.4.0-18397875f260a08e-libjansi.so: failed to map segment from shared object build 09-Sep-2022 11:31:12 [INFO] Scanning for projects... build 09-Sep-2022 11:31:12 [INFO] Downloading from public: https://myserver/nexus/repository/public/org/apache/maven/plugins/maven-antrun-plugin/3.1.0/maven-antrun-plugin-3.1.0.pom build 09-Sep-2022 11:31:13 [INFO] Downloaded from public: https://myserver/nexus/repository/public/org/apache/maven/plugins/maven-antrun-plugin/3.1.0/maven-antrun-plugin-3.1.0.pom (9.1 kB at 6.4 kB/s) build 09-Sep-2022 11:31:13 [INFO] Downloading from public: https://myserver/nexus/repository/public/org/apache/maven/plugins/maven-antrun-plugin/3.1.0/maven-antrun-plugin-3.1.0.jar build 09-Sep-2022 11:31:14 [INFO] Downloaded from public: https://myserver/nexus/repository/public/org/apache/maven/plugins/maven-antrun-plugin/3.1.0/maven-antrun-plugin-3.1.0.jar (41 kB at 443 kB/s) build 09-Sep-2022 11:31:14 [INFO] build 09-Sep-2022 11:31:14 [INFO] -------------------------< PROJ:loadinglibs >------------------------- build 09-Sep-2022 11:31:14 [INFO] Building loadinglibs 1.0 build 09-Sep-2022 11:31:14 [INFO] --------------------------------[ jar ]--------------------------------- build 09-Sep-2022 11:31:14 [INFO] build 09-Sep-2022 11:31:14 [INFO] --- maven-enforcer-plugin:3.1.0:enforce (enforce-beanshell) @ loadinglibs --- build 09-Sep-2022 11:31:14 [INFO] Downloading from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-api/3.1.0/enforcer-api-3.1.0.pom build 09-Sep-2022 11:31:14 [INFO] Downloaded from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-api/3.1.0/enforcer-api-3.1.0.pom (0 B at 0 B/s) build 09-Sep-2022 11:31:14 [INFO] Downloading from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-rules/3.1.0/enforcer-rules-3.1.0.pom build 09-Sep-2022 11:31:14 [INFO] Downloaded from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-rules/3.1.0/enforcer-rules-3.1.0.pom (0 B at 0 B/s) build 09-Sep-2022 11:31:14 [INFO] Downloading from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-api/3.1.0/enforcer-api-3.1.0.jar build 09-Sep-2022 11:31:14 [INFO] Downloading from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-rules/3.1.0/enforcer-rules-3.1.0.jar build 09-Sep-2022 11:31:14 [INFO] Downloaded from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-rules/3.1.0/enforcer-rules-3.1.0.jar (0 B at 0 B/s) build 09-Sep-2022 11:31:14 [INFO] Downloaded from public: https://myserver/nexus/repository/public/org/apache/maven/enforcer/enforcer-api/3.1.0/enforcer-api-3.1.0.jar (0 B at 0 B/s) build 09-Sep-2022 11:31:14 java.io.tmpdir: /opt/myproject/tmp/PROJ-TT-JOB1 build 09-Sep-2022 11:31:14 [INFO] build 09-Sep-2022 11:31:14 [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ loadinglibs --- build 09-Sep-2022 11:31:14 [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! build 09-Sep-2022 11:31:14 [INFO] skip non existing resourceDirectory /opt/myproject/bamboo-agent-home/xml-data/build-dir/PROJ-TT-JOB1/src/main/resources build 09-Sep-2022 11:31:14 [INFO] build 09-Sep-2022 11:31:14 [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ loadinglibs --- build 09-Sep-2022 11:31:14 [INFO] No sources to compile build 09-Sep-2022 11:31:14 [INFO] build 09-Sep-2022 11:31:14 [INFO] --- maven-antrun-plugin:3.1.0:run (default) @ loadinglibs --- build 09-Sep-2022 11:31:15 [INFO] Executing tasks build 09-Sep-2022 11:31:15 ------- Ant diagnostics report ------- build 09-Sep-2022 11:31:15 Apache Ant(TM) version 1.10.12 compiled on October 13 2021 build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 Implementation Version build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 core tasks : 1.10.12 in file:/opt/myproject/commons/maven-localrepo/org/apache/ant/ant/1.10.12/ant-1.10.12.jar build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 ANT PROPERTIES build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 ant.version: Apache Ant(TM) version 1.10.12 compiled on October 13 2021 build 09-Sep-2022 11:31:15 ant.java.version: 11 build 09-Sep-2022 11:31:15 Is this the Apache Harmony VM? no build 09-Sep-2022 11:31:15 Is this the Kaffe VM? no build 09-Sep-2022 11:31:15 Is this gij/gcj? no build 09-Sep-2022 11:31:15 ant.core.lib: /opt/myproject/commons/maven-localrepo/org/apache/ant/ant/1.10.12/ant-1.10.12.jar build 09-Sep-2022 11:31:15 ant.home: null build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 ANT_HOME/lib jar listing build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 ant.home: null build 09-Sep-2022 11:31:15 No such directory. build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 USER_HOME/.ant/lib jar listing build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 user.home: /opt/myproject build 09-Sep-2022 11:31:15 No such directory. build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 Tasks availability build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 junitreport : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 sshsession : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 telnet : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 scp : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 antlr : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 imageio : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 rexec : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 image : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 junit : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 jdepend : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 splash : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 xz : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 sshexec : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 netrexxc : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 ftp : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 unxz : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 junitlauncher : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 sound : Not Available (the implementation class is not present) build 09-Sep-2022 11:31:15 A task being missing/unavailable should only matter if you are trying to use it build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 org.apache.env.Which diagnostics build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 Not available. build 09-Sep-2022 11:31:15 Download it at https://xml.apache.org/commons/ build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 XML Parser information build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 XML Parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl build 09-Sep-2022 11:31:15 XML Parser Location: unknown build 09-Sep-2022 11:31:15 Namespace-aware parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser build 09-Sep-2022 11:31:15 Namespace-aware parser Location: unknown build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 XSLT Processor information build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 XSLT Processor : com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl build 09-Sep-2022 11:31:15 XSLT Processor Location: unknown build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 System properties build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 awt.toolkit : sun.awt.X11.XToolkit build 09-Sep-2022 11:31:15 java.specification.version : 11 build 09-Sep-2022 11:31:15 sun.cpu.isalist : build 09-Sep-2022 11:31:15 sun.jnu.encoding : UTF-8 build 09-Sep-2022 11:31:15 java.class.path : /opt/myproject/commons/maven-3.8.6/boot/plexus-classworlds-2.6.0.jar build 09-Sep-2022 11:31:15 java.vm.vendor : Oracle Corporation build 09-Sep-2022 11:31:15 sun.arch.data.model : 64 build 09-Sep-2022 11:31:15 java.vendor.url : https://openjdk.java.net/ build 09-Sep-2022 11:31:15 user.timezone : Europe/Luxembourg build 09-Sep-2022 11:31:15 maven.conf : /opt/myproject/commons/maven-3.8.6/conf build 09-Sep-2022 11:31:15 os.name : Linux build 09-Sep-2022 11:31:15 java.vm.specification.version : 11 build 09-Sep-2022 11:31:15 sun.java.launcher : SUN_STANDARD build 09-Sep-2022 11:31:15 user.country : GB build 09-Sep-2022 11:31:15 sun.boot.library.path : /opt/myproject/commons/jdk-11.0.14/lib build 09-Sep-2022 11:31:15 sun.java.command : org.codehaus.plexus.classworlds.launcher.Launcher --batch-mode -Djava.io.tmpdir=/opt/myproject/tmp/PROJ-TT-JOB1 compile dependency:resolve enforcer:enforce build 09-Sep-2022 11:31:15 jdk.debug : release build 09-Sep-2022 11:31:15 maven.home : /opt/myproject/commons/maven-3.8.6 build 09-Sep-2022 11:31:15 sun.cpu.endian : little build 09-Sep-2022 11:31:15 user.home : /opt/myproject build 09-Sep-2022 11:31:15 user.language : en build 09-Sep-2022 11:31:15 java.specification.vendor : Oracle Corporation build 09-Sep-2022 11:31:15 jansi.mode : strip build 09-Sep-2022 11:31:15 java.version.date : 2022-01-18 build 09-Sep-2022 11:31:15 java.home : /opt/myproject/commons/jdk-11.0.14 build 09-Sep-2022 11:31:15 file.separator : / build 09-Sep-2022 11:31:15 java.vm.compressedOopsMode : Zero based build 09-Sep-2022 11:31:15 line.separator : build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 java.specification.name : Java Platform API Specification build 09-Sep-2022 11:31:15 java.vm.specification.vendor : Oracle Corporation build 09-Sep-2022 11:31:15 java.awt.graphicsenv : sun.awt.X11GraphicsEnvironment build 09-Sep-2022 11:31:15 sun.management.compiler : HotSpot 64-Bit Tiered Compilers build 09-Sep-2022 11:31:15 java.runtime.version : 11.0.14+8-LTS-263 build 09-Sep-2022 11:31:15 user.name : studio build 09-Sep-2022 11:31:15 path.separator : : build 09-Sep-2022 11:31:15 os.version : 4.18.0-348.12.2.el8_5.x86_64 build 09-Sep-2022 11:31:15 java.runtime.name : Java(TM) SE Runtime Environment build 09-Sep-2022 11:31:15 file.encoding : UTF-8 build 09-Sep-2022 11:31:15 guice.disable.misplaced.annotation.check : true build 09-Sep-2022 11:31:15 java.vm.name : Java HotSpot(TM) 64-Bit Server VM build 09-Sep-2022 11:31:15 java.vendor.version : 18.9 build 09-Sep-2022 11:31:15 java.vendor.url.bug : https://bugreport.java.com/bugreport/ build 09-Sep-2022 11:31:15 java.io.tmpdir : /opt/myproject/tmp/PROJ-TT-JOB1 build 09-Sep-2022 11:31:15 java.version : 11.0.14 build 09-Sep-2022 11:31:15 user.dir : /opt/myproject/bamboo-agent-home/xml-data/build-dir/PROJ-TT-JOB1 build 09-Sep-2022 11:31:15 os.arch : amd64 build 09-Sep-2022 11:31:15 maven.multiModuleProjectDirectory : /opt/myproject/bamboo-agent-home/xml-data/build-dir/PROJ-TT-JOB1 build 09-Sep-2022 11:31:15 java.vm.specification.name : Java Virtual Machine Specification build 09-Sep-2022 11:31:15 java.awt.printerjob : sun.print.PSPrinterJob build 09-Sep-2022 11:31:15 sun.os.patch.level : unknown build 09-Sep-2022 11:31:15 java.library.path : /opt/myproject/commons/subversion-1.8.19/lib:/opt/myproject/commons/httpd-2.4.20/lib:/opt/myproject/commons/lib/serf-1.3.8/lib:/opt/myproject/commons/sqlplus-21.7.0.0.0:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib build 09-Sep-2022 11:31:15 java.vendor : Oracle Corporation build 09-Sep-2022 11:31:15 java.vm.info : mixed mode build 09-Sep-2022 11:31:15 java.vm.version : 11.0.14+8-LTS-263 build 09-Sep-2022 11:31:15 classworlds.conf : /opt/myproject/commons/maven-3.8.6/bin/m2.conf build 09-Sep-2022 11:31:15 sun.io.unicode.encoding : UnicodeLittle build 09-Sep-2022 11:31:15 library.jansi.path : /opt/myproject/commons/maven-3.8.6/lib/jansi-native build 09-Sep-2022 11:31:15 java.class.version : 55.0 build 09-Sep-2022 11:31:15
build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 Temp dir build 09-Sep-2022 11:31:15 ------------------------------------------- build 09-Sep-2022 11:31:15 Temp dir is /opt/myproject/tmp/PROJ-TT-JOB1 build 09-Sep-2022 11:31:16 Temp dir is writeable build 09-Sep-2022 11:31:16 Temp dir alignment with system clock is 0 ms build 09-Sep-2022 11:31:16
build 09-Sep-2022 11:31:16 ------------------------------------------- build 09-Sep-2022 11:31:16 Locale information build 09-Sep-2022 11:31:16 ------------------------------------------- build 09-Sep-2022 11:31:16 Timezone Central European Standard Time offset=7200000 build 09-Sep-2022 11:31:16
build 09-Sep-2022 11:31:16 ------------------------------------------- build 09-Sep-2022 11:31:16 Proxy information build 09-Sep-2022 11:31:16 ------------------------------------------- build 09-Sep-2022 11:31:16 Java1.5+ proxy settings: build 09-Sep-2022 11:31:16 Direct connection build 09-Sep-2022 11:31:16
build 09-Sep-2022 11:31:16
build 09-Sep-2022 11:31:16 [INFO] Executed tasks build 09-Sep-2022 11:31:16 [INFO] build 09-Sep-2022 11:31:16 [INFO] --- maven-dependency-plugin:2.8:resolve (default-cli) @ loadinglibs --- build 09-Sep-2022 11:31:17 [INFO] build 09-Sep-2022 11:31:17 [INFO] The following files have been resolved: build 09-Sep-2022 11:31:17 [INFO] none build 09-Sep-2022 11:31:17 [INFO] build 09-Sep-2022 11:31:17 [INFO] build 09-Sep-2022 11:31:17 [INFO] --- maven-enforcer-plugin:3.1.0:enforce (default-cli) @ loadinglibs --- build 09-Sep-2022 11:31:17 [INFO] ------------------------------------------------------------------------ build 09-Sep-2022 11:31:17 [INFO] BUILD FAILURE build 09-Sep-2022 11:31:17 [INFO] ------------------------------------------------------------------------ build 09-Sep-2022 11:31:17 [INFO] Total time: 5.409 s build 09-Sep-2022 11:31:17 [INFO] Finished at: 2022-09-09T11:31:17+02:00 build 09-Sep-2022 11:31:17 [INFO] ------------------------------------------------------------------------ build 09-Sep-2022 11:31:17 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.1.0:enforce (default-cli) on project loadinglibs: No rules are configured. Use the skip flag if you want to disable execution. -> [Help 1] build 09-Sep-2022 11:31:17 [ERROR] build 09-Sep-2022 11:31:17 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. build 09-Sep-2022 11:31:17 [ERROR] Re-run Maven using the -X switch to enable full debug logging. build 09-Sep-2022 11:31:17 [ERROR] build 09-Sep-2022 11:31:17 [ERROR] For more information about the errors and possible solutions, please read the following articles: build 09-Sep-2022 11:31:17 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException simple 09-Sep-2022 11:31:17 Failing task since return code of [/opt/myproject/commons/maven-3.8.6/bin/mvn --batch-mode -Djava.io.tmpdir=/opt/myproject/tmp/PROJ-TT-JOB1 compile dependency:resolve enforcer:enforce] was 1 while expected 0

@michael-o can you please have a look as well, as Maven is using jansi, which is not behaving corrrectly, and at the end of the day, we are Maven users, we do not care much about the dependencies behind Maven...

Thank you

flopma commented 1 year ago

It's getting even more interesting, the jansi.tmpdir is not taken into account. See below

(control:~) ls $HOME/tmp
core-js-banners       v8-compile-cache-6661
yarn--1655825916229-0.1790109880841968
yarn--1655825916229-0.4796588108858555
(control:~) mvn -Djansi.tmpdir=$HOME/tmp --version
Failed to load native library:jansi-2.4.0-8248ee3780e1fb9a-libjansi.so. The native library file at /tmp/jansi-2.4.0-8248ee3780e1fb9a-libjansi.so is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location.  osinfo: Linux/x86_64
java.lang.UnsatisfiedLinkError: /tmp/jansi-2.4.0-8248ee3780e1fb9a-libjansi.so: /tmp/jansi-2.4.0-8248ee3780e1fb9a-libjansi.so: failed to map segment from shared object
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /opt/maven-3.8.6
Java version: 11.0.14, vendor: Oracle Corporation, runtime: /opt/jdk-11.0.14
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-348.12.2.el8_5.x86_64", arch: "amd64", family: "unix"
michael-o commented 1 year ago

Without having analyzed it further, you are using a misconception/documentation in Maven which I am going to document/change in Maven 4, maybe even 3.9.0: with mvn ... -Dfoo=bar you do NOT pass a system property, but a user property which unfortunately promoted to a system property. Jansi uses static methods which are run before Maven has a change to set that promoted property.

Please try the following and report: export MAVEN_OPTS=-Djansi.tmpdir=$HOME/tmp; mvn -v

@slawekjaranowski @cstamas @gnodet @hboutemy This is something I told you about that the documentation and mvn -h is plain wrong. You cannot reasonably set system props via the mvn command.

PS: @flopma This isn't your fault. We have failed to update code and docs in time.

michael-o commented 1 year ago

@slawekjaranowski We need fix this is Verifier mid-term and all other components to avoid such cases.

flopma commented 1 year ago

Thx for your prompt feedback Michael. I tried export MAVEN_OPTS=-Djansi.tmpdir=$HOME/tmp; mvn -v and export MAVEN_OPTS=-Djava.io.tmpdir=$HOME/tmp; mvn -v in my case, and indeed, the warning from jansi is gone.

Ok, then your explanation explains everything about the behavior I have. I will try using $HOME/.mavenrc to set a MAVEN_OPTS because the example about is run inside Atlassian Bamboo and it is actually Bamboo which is using the -Djava.io.tmpdir as a maven user property. It seems a lot of users are confused about this. I believe -D parameters like that which are interpreted by Maven should not be automatically set as system properties, because it is then confusing...

I will also open a support case with Atlassian to explain them what you just described...

So I guess there is no bug in jansi. The code is perfectly fine. It's just dummy Maven users :see_no_evil: :sweat_smile:

Thx

michael-o commented 1 year ago

Thx for your prompt feedback Michael. I tried export MAVEN_OPTS=-Djansi.tmpdir=$HOME/tmp; mvn -v and export MAVEN_OPTS=-Djava.io.tmpdir=$HOME/tmp; mvn -v in my case, and indeed, the warning from jansi is gone.

Ok, then your explanation explains everything about the behavior I have. I will try using $HOME/.mavenrc to set a MAVEN_OPTS because the example about is run inside Atlassian Bamboo and it is actually Bamboo which is using the -Djava.io.tmpdir as a maven user property. It seems a lot of users are confused about this. I believe -D parameters like that which are interpreted by Maven should not be automatically set as system properties, because it is then confusing...

There is a better way that setting a custom tempdir. Put the shared library into a separate directory, e.g., /opt/jansi/lib/libjansi.so and set -Dlibrary.jansi.path=/opt/jansi/lib. This will completely avoid the copying and deleting of the shared library and save you startup time. Ideally, the library is on the loader's library path, or alternatively LD_LIBRARY_PATH and you don't need to configure Maven at all. If you go that route, remove the lib form the MAVEN_HOME dir.

Bamboo which is using the -Djava.io.tmpdir as a maven user property. It seems a lot of users are confused about this. I believe -D parameters like that which are interpreted by Maven should not be automatically set as system properties, because it is then confusing...

Your understanding is absolutely correct. It is a total mess and it most not be promoted because it is not guaranteed to work as people expect. This is the spot which makes everything confusing. I plan to remove this mid term, but until then we need to do a lot of cleanup.

I will also open a support case with Atlassian to explain them what you just described...

So I guess there is no bug in jansi. The code is perfectly fine. It's just dummy Maven users 🙈 😅

Thx