Eskibear / node-jdk-utils

A collection of Java related utils.
MIT License
10 stars 5 forks source link

[Bug] Find wrong Java Home for some distribution using sdkman #17

Open jdneo opened 1 year ago

jdneo commented 1 year ago
Screenshot 2023-10-07 at 11 01 19

If the Gradle Java Home is set to /Users/sheche/.sdkman/candidates/java/8.0.372-zulu, the project import will fail due to:

Caused by: org.gradle.launcher.daemon.client.DaemonConnectionException: The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch: 
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/Users/sheche/.sdkman/candidates/java/8.0.372-zulu,daemonRegistryDir=/Users/sheche/.gradle/daemon,pid=79226,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=utf8,-Duser.country=CN,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=7bf45064-7e54-403d-8966-fb34bbe84800,javaHome=/Users/sheche/.sdkman/candidates/java/8.0.372-zulu/zulu-8.jdk/Contents/Home,daemonRegistryDir=/Users/sheche/.gradle/daemon,pid=79250,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=utf8,-Duser.country=CN,-Duser.language=en,-Duser.variant]
Eskibear commented 1 year ago

Please go fixing it :) You probably can follow below:

https://github.com/Eskibear/node-jdk-utils/blob/e0a9e670132806647e2a5fb82feb58eee098007d/src/from/gradle.ts#L44-L49

Eskibear commented 1 year ago
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/Users/sheche/.sdkman/candidates/java/8.0.372-zulu,daemonRegistryDir=/Users/sheche/.gradle/daemon,pid=79226,idleTimeout=null,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=utf8,-Duser.country=CN,-Duser.language=en,-Duser.variant]
Actual: DefaultDaemonContext[uid=7bf45064-7e54-403d-8966-fb34bbe84800,javaHome=/Users/sheche/.sdkman/candidates/java/8.0.372-zulu/zulu-8.jdk/Contents/Home,daemonRegistryDir=/Users/sheche/.gradle/daemon,pid=79250,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=utf8,-Duser.country=CN,-Duser.language=en,-Duser.variant]

In SDKMan, the symlinks are correctly created, pointing to ./Content/Home subfolders. Looks like it's the issue of Gradle Daemon's java home check.