emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
650 stars 90 forks source link

jdtls installation fails mvnw.cmd: command not found #401

Open andreaskundig opened 2 years ago

andreaskundig commented 2 years ago

I installed lsp java in doom emacs (latest version) on windows 10. The first time I open a java file, emacs proposes to install jdtls. I accept, but I get the following error:

-*- mode: compilation; default-directory: "~/AppData/Local/Temp/lsp-java-installQGKlPd/" -*-
Comint started at Sun Aug 21 18:50:53

mvnw.cmd -Djdt.js.server.root\=c\:/Users/andre/doom-emacs/.local/etc/lsp/eclipse.jdt.ls/ -Djunit.runner.root\=c\:/Users/andre/doom-emacs/.local/cache/eclipse.jdt.ls/test-runner/ -Djunit.runner.fileName\=junit-platform-console-standalone.jar -Djava.debug.root\=c\:/Users/andre/doom-emacs/.local/etc/lsp/eclipse.jdt.ls/bundles clean package -Djdt.download.url\=https\://download.eclipse.org/jdtls/milestones/1.5.0/jdt-language-server-1.5.0-202110191539.tar.gz
/usr/bin/bash: mvnw.cmd: command not found

Comint exited abnormally with code 127 at Sun Aug 21 18:50:54

The same command fails when I run it by hand in git bash

cd ~/doom-emacs/.local/straight/repos/lsp-java/install
mvnw.cmd -Djdt.js.server.root[etc...]

However it works when I add the path in front of the executable

./mvnw.cmd -Djdt.js.server.root[etc...]
daveloyall commented 1 year ago

I came here to report my own problem, but it might be the same as this one @andreaskundig reported back in August.

Here is mine:

-*- mode: compilation; default-directory: "c:/Users/FIRST~1.LAS/AppData/Local/Temp/2/lsp-java-installnOskvq/" -*-
Comint started at Fri Feb  3 16:54:31

mvnw.cmd -Djdt.js.server.root\=c\:/bin/msys64/home/firstname.lastname/.emacs.d/.cache/lsp/eclipse.jdt.ls/ -Djunit.runner.root\=c\:/bin/msys64/home/firstname.lastname/.emacs.d/eclipse.jdt.ls/test-runner/ -Djunit.runner.fileName\=junit-platform-console-standalone.jar -Djava.debug.root\=c\:/bin/msys64/home/firstname.lastname/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles clean package -Djdt.download.url\=https\://download.eclipse.org/jdtls/milestones/1.12.0/jdt-language-server-1.12.0-202206011637.tar.gz
/usr/bin/bash: line 1: mvnw.cmd: command not found

Comint exited abnormally with code 127 at Fri Feb  3 16:54:31

I'm not using git-bash (aka git from git-scm.org, which comes with bash) but I am using msys2 (from msys2.org, which also comes with bash).

And I'm not using doom-emacs, I'm using mingw64/mingw-w64-x86_64-emacs 28.2-2 which is a package that is available within the msys2 environment.

Anyway, I think the problem is that the jdtls installation routines are getting a little confused about whether these systems are unix, or if they are Microsoft Windows. Part of the installation routines (or something) choose to invoke GNU Bash, but some other part chooses to pass the argument mvnw.cmd to that bash process...

I know a shell script is also available (./mvnw)... so whenever a shell interpreter is used, that script should be used, too. The mvnw.cmd file should only be used if cmd.exe was invoked. (I guess.)

daveloyall commented 1 year ago

I forgot to mention.. the emacs package in msys2 is quite confused itself.

I see both these strings on my screen right now.. Different parts of the thing are seeing different home directories for my user:

c:/Users/firstname.lastname/
c:/bin/msys64/home/firstname.lastname/