You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/04/24 09:01:27 UTC

[GitHub] [maven-mvnd] imbennie opened a new issue, #619: Problem when running in Cygwin with ENV “JAVA_HOME” itself.

imbennie opened a new issue, #619:
URL: https://github.com/apache/maven-mvnd/issues/619

   This problem seems like #156 but has a little difference.
   
   I had SDKMAN in my Cygiwn and have several java versions installed.
   So Cygwin has its own `JAVA_HOME`.
   
   ```
   ~ » echo $JAVA_HOME        
   
   /home/Bennie/.sdkman/candidates/java/current
   ```
   
   And when i checkout mvnd version
   ```
   ~ » mvnd -v                                                                                                                                                                                                                 
   mvnd native client 0.7.1-windows-amd64 (97c587c11383a67b5bd0ff8388bd94c694b91c1e)
   Terminal: org.jline.terminal.impl.jansi.win.JansiWinSysTerminal
   Exception in thread "main" java.lang.RuntimeException: Could not get a real path from path \home\Bennie\.sdkman\candidates\java\current
           at org.mvndaemon.mvnd.client.DaemonParameters.javaHome(DaemonParameters.java:144)
           at org.mvndaemon.mvnd.client.DaemonConnector.connect(DaemonConnector.java:99)
           at org.mvndaemon.mvnd.client.DefaultClient.execute(DefaultClient.java:272)
           at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:118)
   ```
   
   That's the problem what is.
   
   
   
   I'm trying `mvnd -v` agin after edit `java.home` in the `conf/mvnd.properties` with following, But still got the same error output before.
   
   ```
   java.home=/home/Bennie/.sdkman/candidates/java/8.0.322-tem
   ```
   
   
   
   After read the #156 I find out maybe the @gnodet doesn't have a `JAVA_HOME` in Cygwin itself which just copied from Windows one.
   
   Thus I unset the JAVA_HOME and ran `mvnd -v` agin.
   
   ```
   ~ » unset JAVA_HOME
   ~ » mvnd -v                                                                                                                     
   mvnd native client 0.7.1-windows-amd64 (97c587c11383a67b5bd0ff8388bd94c694b91c1e)
   Terminal: org.jline.terminal.impl.jansi.win.JansiWinSysTerminal
   Exception in thread "main" java.lang.RuntimeException: Could not get a real path from path \home\Bennie\.sdkman\candidates\java\8.0.322-tem
           at org.mvndaemon.mvnd.client.DaemonParameters.javaHome(DaemonParameters.java:144)
           at org.mvndaemon.mvnd.client.DaemonConnector.connect(DaemonConnector.java:99)
           at org.mvndaemon.mvnd.client.DefaultClient.execute(DefaultClient.java:272)
           at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:118)
   ```
   
   This time the `java.home` path in output is point to our's one. Verified that the `unset JAVA_HOME` operation is valid.
   
   
   
   But the problem still does what it does.
   
   
   
   I  checked out the #156 bug-fixed details. Found out the `java.home` path start with `\cygdrive\`, So edit `java.home` in the `conf/mvnd.properties`  again.
   
   Then It's just worked.
   
   ```
   java.home=/cygdrive/d/Tools/cygwin/home/Bennie/.sdkman/candidates/java/8.0.322-tem
   
   ~ » mvnd -v
   
   mvnd native client 0.7.1-windows-amd64 (97c587c11383a67b5bd0ff8388bd94c694b91c1e)
   Terminal: org.jline.terminal.impl.jansi.win.JansiWinSysTerminal
   Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
   Maven home: D:\Tools\cygwin\home\Bennie\.sdkman\candidates\mvnd\0.7.1\mvn
   Java version: 1.8.0_322, vendor: Temurin, runtime: D:\Tools\cygwin\home\Bennie\.sdkman\candidates\java\8.0.322-tem\jre
   Default locale: zh_CN, platform encoding: GBK
   OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
   ```
   
   
   
   Finally:
   1. Is there a good way to solve this problem?
   2. This is may be a bug? due the `java.home` property override by `$JAVA_HOME`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-mvnd] matinh commented on issue #619: Problem when running in Cygwin with an existed env variable “JAVA_HOME”.

Posted by "matinh (via GitHub)" <gi...@apache.org>.
matinh commented on issue #619:
URL: https://github.com/apache/maven-mvnd/issues/619#issuecomment-1569587503

   Just for the records and maybe to help someone else. I had a very similar problem but without the cygwin environment. `mvnd` always reported some not existing path (old java version) with the same exception as above. After some searching in environment variables and config files, I found the reason: I had an old `~/.m2/mvnd.properties` with java.home set to the obsolete path. Removing this file solved the problem.
   
   Maybe it would be nice if `mvnd` would report where it got the java path from, at least in case of an error.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-mvnd] digulla commented on issue #619: Problem when running in Cygwin with an existed env variable “JAVA_HOME”.

Posted by GitBox <gi...@apache.org>.
digulla commented on issue #619:
URL: https://github.com/apache/maven-mvnd/issues/619#issuecomment-1142317006

   My suggestion would be to check whether `cygpath` is on the PATH or detect cygwin using `uname -s`. If a path doesn't work, try to run it through `cygpath --windows ` and try again.
   
   Something like using this everywhere:
   
       File path = resolveLocalPath(...)
   
   and then having code like this in resolveLocalPath():
   
       if file.exists() return file;
       if (cygwin) { // cygwin
           String mightWork = runOSCommand("cygpath", "--windows", file.toString());
           File f = new File(mightWork);
           if (f.exists()) { return file)
       }
   
   `uname -s` returns `CYGWIN_NT-10.0-19042`. I suggest to check for `String.startsWith("CYGWIN")`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven-mvnd] digulla commented on issue #619: Problem when running in Cygwin with an existed env variable “JAVA_HOME”.

Posted by GitBox <gi...@apache.org>.
digulla commented on issue #619:
URL: https://github.com/apache/maven-mvnd/issues/619#issuecomment-1142322717

   Workaround: Run this command to set JAVA_HOME in such a way that mvnd can use it:
   
       export JAVA_HOME="$(cygpath --windows ~/.sdkman/candidates/java/current)"


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org