lsp-mode install java eclipse.jdt.ls server 安装失败

执行你的代码后,出现如下错误:

Debugger entered--Lisp error: (wrong-type-argument processp (((t lsp-java-progress-string)) ssh-deploy--mode-line-status-text org-mode-line-string))
  process-buffer((((t lsp-java-progress-string)) ssh-deploy--mode-line-status-text org-mode-line-string))
  (display-buffer (process-buffer (call-interactively 'lsp-install-server)))
  (let ((process-environment (cl-copy-list process-environment))) (setenv "http_proxy" "127.0.0.1:8118") (setenv "https_proxy" "127.0.0.1:8118") (display-buffer (process-buffer (call-interactively 'lsp-install-server))))
  (progn (let ((process-environment (cl-copy-list process-environment))) (setenv "http_proxy" "127.0.0.1:8118") (setenv "https_proxy" "127.0.0.1:8118") (display-buffer (process-buffer (call-interactively 'lsp-install-server)))))
  (unwind-protect (progn (let ((process-environment (cl-copy-list process-environment))) (setenv "http_proxy" "127.0.0.1:8118") (setenv "https_proxy" "127.0.0.1:8118") (display-buffer (process-buffer (call-interactively 'lsp-install-server))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((process-environment (cl-copy-list process-environment))) (setenv "http_proxy" "127.0.0.1:8118") (setenv "https_proxy" "127.0.0.1:8118") (display-buffer (process-buffer (call-interactively 'lsp-install-server))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((process-environment (cl-copy-list process-environment))) (setenv "http_proxy" "127.0.0.1:8118") (setenv "https_proxy" "127.0.0.1:8118") (display-buffer (process-buffer (call-interactively ...))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  (let ((url-proxy-services '(("http" . "127.0.0.1:8118") ("https" . "127.0.0.1:8118") ("ftp" . "127.0.0.1:8118") ("no_proxy" . "^\\(localhost\\|127.0.0.1\\|192.168.*\\|10.*\\)")))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((process-environment ...)) (setenv "http_proxy" "127.0.0.1:8118") (setenv "https_proxy" "127.0.0.1:8118") (display-buffer (process-buffer ...)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))
  (progn (let ((url-proxy-services '(("http" . "127.0.0.1:8118") ("https" . "127.0.0.1:8118") ("ftp" . "127.0.0.1:8118") ("no_proxy" . "^\\(localhost\\|127.0.0.1\\|192.168.*\\|10.*\\)")))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let (...) (setenv "http_proxy" "127.0.0.1:8118") (setenv "https_proxy" "127.0.0.1:8118") (display-buffer ...))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))))
  (unwind-protect (progn (let ((url-proxy-services '(("http" . "127.0.0.1:8118") ("https" . "127.0.0.1:8118") ("ftp" . "127.0.0.1:8118") ("no_proxy" . "^\\(localhost\\|127.0.0.1\\|192.168.*\\|10.*\\)")))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ... ... ... ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((url-proxy-services '(... ... ... ...))) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...) (and ... ...)))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((url-proxy-services '...)) (let ((temp-buffer ...)) (save-current-buffer (set-buffer temp-buffer) (unwind-protect ... ...))))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  eval((let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((url-proxy-services ...)) (let (...) (save-current-buffer ... ...)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  eros-eval-last-sexp(nil)
  funcall-interactively(eros-eval-last-sexp nil)
  call-interactively(eros-eval-last-sexp nil nil)
  command-execute(eros-eval-last-sexp)

看了 lsp-install-server 的源代码,看不出是否返回的是一个 process 。你那边测试正常么?

这是内部用的 maven 的命令,你可以试试

mvn \
  -Djdt.js.server.root=/home/larry/.emacs.d/eclipse.jdt.ls/server \
  -Djunit.runner.root=/home/larry/.emacs.d/eclipse.jdt.ls/test-runner \
  -Djunit.runner.fileName=/home/larry/.emacs.d/eclipse.jdt.ls/test-runner/junit-platform-console-standalone.jar \
  -Djava.debug.root=/home/larry/.emacs.d/eclipse.jdt.ls/server/bundles \
  -Djdt.download.url=https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz \
  package

https://github.com/xqliu/dotfiles/tree/master/lsp/java

我这边测试正常。

我设置错误的代理才会出现你这个情况,而且如果把 (display-buffer (process-buffer 去掉,得到的真正错误信息是:

Contacting host: raw.githubusercontent.com:443
LSP :: Server jdtls install process failed with the following error message:
127.0.0.1/XXXX nodename nor servname provided, or not known.

我写了一个一键运行的最小配置:test-lsp-jdtls-installation.el

我在浏览器里访问了一下 raw.githubusercontent.com:443 无法访问,就算我开启浏览器代理插件也不行。估计是网络哪里设置了障碍。我代理也是一直访问不了google。之前一段时间还能看youtube,现在也打不开了。都是一样的报错。

– UPDATE – 算了,这个方案能执行就行。等我之后再处理代理的问题。

谢谢,mark

不想折腾代理的可以设置下这个变量

  (setq lsp-java--download-root "https://gitee.com/liujiacai/lsp-java/raw/master/install/")

其实就是把 lsp-java/install at master · emacs-lsp/lsp-java · GitHub 目录下载下来(利用 gitee 来做中转),然后执行

/usr/local/opt/jenv/versions/1.8/bin/java -classpath \ /usr/local/Cellar/maven/3.6.3/libexec/boot/plexus-classworlds-2.6.0.jar \ 
-Dclassworlds.conf=/usr/local/Cellar/maven/3.6.3/libexec/bin/m2.conf \
-Dmaven.home=/usr/local/Cellar/maven/3.6.3/libexec \
-Dlibrary.jansi.path=/usr/local/Cellar/maven/3.6.3/libexec/lib/jansi-native \
-Dmaven.multiModuleProjectDirectory=/var/folders/gr/6044y_957fl31k5j89f8pxtw0000gp/T/lsp-java-installLOqaag org.codehaus.plexus.classworlds.launcher.Launcher \
-Djdt.js.server.root=$HOME/.emacs.d/ignore/lsp-server/eclipse.jdt.ls/ \
-Djunit.runner.root=$HOME/.emacs.d/eclipse.jdt.ls/test-runner/ \
-Djunit.runner.fileName=junit-platform-console-standalone.jar \
-Djava.debug.root=$HOME/.emacs.d/ignore/lsp-server/eclipse.jdt.ls/bundles clean package \
-Djdt.download.url=https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz

大家仿照着改改就行。

可悲的是,jdt 现在只支持 jdk11+ 了。。。jdk8 只用能老版本的了

测试了下,最后一个版本支持 jdk8 的是 0.57.0,最终的配置

(use-package lsp-java
  :hook (java-mode . lsp-deferred)
  :init
  (setq lsp-java--download-root "https://gitee.com/liujiacai/lsp-java/raw/master/install/"
        lsp-java-workspace-dir (expand-file-name "workspace" my/ignore-directory)
        dap-java-test-runner (expand-file-name "eclipse.jdt.ls/test-runner/junit-platform-console-standalone.jar" my/ignore-directory)
        ;; jdk8 isn't supported in latest version
        ;; https://github.com/emacs-lsp/lsp-java/issues/249
        lsp-java-jdt-download-url "http://mirrors.ustc.edu.cn/eclipse/jdtls/milestones/0.57.0/jdt-language-server-0.57.0-202006172108.tar.gz")
  )
2 个赞