jenv: jenv Maven plugin does not pick up the right version

I’m using Jenv 0.5.0 and the jenv Maven plugin is already enabled. If I switch versions globally or locally, Maven does not pick up the change. jenv doctor reports no issues.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 22 (9 by maintainers)

Commits related to this issue

Most upvoted comments

The bug still appears, only jenv exec mvn ... seems to work:

➜  dcb-admin git:(master) jenv version
1.7 (set by /Users/fbiville/workspace/dcb-admin/.java-version)
➜  dcb-admin git:(master) mvn -version
executing mvnw instead of mvn
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /Users/fbiville/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9
Java version: 11.0.1, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.4", arch: "x86_64", family: "mac"
➜  dcb-admin git:(master) jenv doctor
[OK]	JAVA_HOME variable probably set by jenv PROMPT
[OK]	Java binaries in path are jenv shims
[OK]	Jenv is correctly loaded
➜  dcb-admin git:(master) jenv disable-plugin maven
maven disabled
➜  dcb-admin git:(master) jenv rehash
➜  dcb-admin git:(master) jenv enable-plugin maven
maven plugin activated
➜  dcb-admin git:(master) jenv version
1.7 (set by /Users/fbiville/workspace/dcb-admin/.java-version)
➜  dcb-admin git:(master) mvn -version
executing mvnw instead of mvn
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /Users/fbiville/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9
Java version: 11.0.1, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.4", arch: "x86_64", family: "mac"
➜  dcb-admin git:(master) jenv exec mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven-deluxe/3.6.3-0/libexec
Java version: 1.7.0_252, vendor: Azul Systems, Inc., runtime: /Library/Java/JavaVirtualMachines/zulu-7.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.4", arch: "x86_64", family: "mac"
➜  dcb-admin git:(master)

Disabling and re-enabling the Maven plugin works like a charm(ing workaround)! Thanks @bric3!

I found the issue, the links of the plugins are linking to 0.4.4, the previous version of jenv installed via homebrew.

> ls -la ~/.jenv/plugins
total 0
drwxr-xr-x   7 b.dutheil  staff  224 Oct  9  2017 .
drwxr-xr-x  27 b.dutheil  staff  864 Jan  2 15:24 ..
lrwxr-xr-x   1 b.dutheil  staff   58 Oct  9  2017 ant -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/ant
lrwxr-xr-x   1 b.dutheil  staff   61 Oct  9  2017 export -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/export
lrwxr-xr-x   1 b.dutheil  staff   61 Oct  9  2017 gradle -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/gradle
lrwxr-xr-x   1 b.dutheil  staff   60 Oct  9  2017 maven -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/maven
lrwxr-xr-x   1 b.dutheil  staff   65 Oct  9  2017 springboot -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/springboot
> disable-plugin maven
maven disabled
> ls -la ~/.jenv/plugins
total 0
drwxr-xr-x   6 b.dutheil  staff  192 Jan 31 17:55 .
drwxr-xr-x  27 b.dutheil  staff  864 Jan  2 15:24 ..
lrwxr-xr-x   1 b.dutheil  staff   58 Oct  9  2017 ant -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/ant
lrwxr-xr-x   1 b.dutheil  staff   61 Oct  9  2017 export -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/export
lrwxr-xr-x   1 b.dutheil  staff   61 Oct  9  2017 gradle -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/gradle
lrwxr-xr-x   1 b.dutheil  staff   65 Oct  9  2017 springboot -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/springboot
> jenv enable-plugin maven
maven plugin activated
> ls -la ~/.jenv/plugins
total 0
drwxr-xr-x   7 b.dutheil  staff  224 Jan 31 17:56 .
drwxr-xr-x  27 b.dutheil  staff  864 Jan  2 15:24 ..
lrwxr-xr-x   1 b.dutheil  staff   58 Oct  9  2017 ant -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/ant
lrwxr-xr-x   1 b.dutheil  staff   61 Oct  9  2017 export -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/export
lrwxr-xr-x   1 b.dutheil  staff   61 Oct  9  2017 gradle -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/gradle
lrwxr-xr-x   1 b.dutheil  staff   60 Jan 31 17:56 maven -> /usr/local/Cellar/jenv/0.5.1/libexec/available-plugins/maven
lrwxr-xr-x   1 b.dutheil  staff   65 Oct  9  2017 springboot -> /usr/local/Cellar/jenv/0.4.4/libexec/available-plugins/springboot

Using jenv rehash don’t work. You have to explicitly disable and enable the plugin again. But it will break again on the next jenv version updated by homebrew.

Instead I believe the plugin activation should link with the opt symlink set by homebrew, e.g. /usr/local/opt/jenv/libexec/available-plugins/maven.