emacs-lsp / lsp-metals

lsp-mode :heart: metals
https://emacs-lsp.github.io/lsp-metals
GNU General Public License v3.0
58 stars 33 forks source link

can't find java. #105

Open madper opened 1 year ago

madper commented 1 year ago

Describe the bug When starting lsp sever the message buffer shows: LSP :: Error from the Language Server: Internal error. (Internal Error) And the output of lsp-log shows:

2023.10.22 20:40:58 ERROR Running process '/Users/madper/source/zring/@@HOMEBREW_JAVA@@/bin/java -version' failed
java.io.IOException: Cannot run program "/Users/madper/source/zring/@@HOMEBREW_JAVA@@/bin/java" (in directory "/Users/madper/source/zring/@@HOMEBREW_JAVA@@"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
    at scala.meta.internal.process.SystemProcess$.run(SystemProcess.scala:45)
    at scala.meta.internal.builds.ShellRunner$.runSync(ShellRunner.scala:154)
    at scala.meta.internal.metals.JdkVersion$.fromShell(JavaInteractiveSemanticdb.scala:214)
    at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$2(JavaInteractiveSemanticdb.scala:205)
    at scala.Option.orElse(Option.scala:477)
    at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$1(JavaInteractiveSemanticdb.scala:205)
    at scala.Option.flatMap(Option.scala:283)
    at scala.meta.internal.metals.JdkVersion$.maybeJdkVersionFromJavaHome(JavaInteractiveSemanticdb.scala:203)
    at scala.meta.internal.metals.MetalsLspService.<init>(MetalsLspService.scala:204)
    at scala.meta.internal.metals.WorkspaceLspService.createService(WorkspaceLspService.scala:170)
    at scala.meta.internal.metals.WorkspaceLspService.$anonfun$workspaceFolders$1(WorkspaceLspService.scala:177)
    at scala.meta.internal.metals.WorkspaceFolders.$anonfun$folderServices$2(WorkspaceFolders.scala:25)
    at scala.collection.immutable.List.map(List.scala:246)
    at scala.meta.internal.metals.WorkspaceFolders.<init>(WorkspaceFolders.scala:25)
    at scala.meta.internal.metals.WorkspaceLspService.<init>(WorkspaceLspService.scala:175)
    at scala.meta.metals.MetalsLanguageServer.createService(MetalsLanguageServer.scala:231)
    at scala.meta.metals.MetalsLanguageServer.initialize(MetalsLanguageServer.scala:170)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.lang.Thread.run(Thread.java:840)
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessImpl.forkAndExec(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
    at java.lang.ProcessImpl.start(ProcessImpl.java:244)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
    at scala.meta.internal.process.SystemProcess$.run(SystemProcess.scala:45)
    at scala.meta.internal.builds.ShellRunner$.runSync(ShellRunner.scala:154)
    at scala.meta.internal.metals.JdkVersion$.fromShell(JavaInteractiveSemanticdb.scala:214)
    at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$2(JavaInteractiveSemanticdb.scala:205)
    at scala.Option.orElse(Option.scala:477)
    at scala.meta.internal.metals.JdkVersion$.$anonfun$maybeJdkVersionFromJavaHome$1(JavaInteractiveSemanticdb.scala:205)
    at scala.Option.flatMap(Option.scala:283)
    at scala.meta.internal.metals.JdkVersion$.maybeJdkVersionFromJavaHome(JavaInteractiveSemanticdb.scala:203)
    at scala.meta.internal.metals.MetalsLspService.<init>(MetalsLspService.scala:204)
    at scala.meta.internal.metals.WorkspaceLspService.createService(WorkspaceLspService.scala:170)
    at scala.meta.internal.metals.WorkspaceLspService.$anonfun$workspaceFolders$1(WorkspaceLspService.scala:177)
    at scala.meta.internal.metals.WorkspaceFolders.$anonfun$folderServices$2(WorkspaceFolders.scala:25)
    at scala.collection.immutable.List.map(List.scala:246)
    at scala.meta.internal.metals.WorkspaceFolders.<init>(WorkspaceFolders.scala:25)
    at scala.meta.internal.metals.WorkspaceLspService.<init>(WorkspaceLspService.scala:175)
    at scala.meta.metals.MetalsLanguageServer.createService(MetalsLanguageServer.scala:231)
    at scala.meta.metals.MetalsLanguageServer.initialize(MetalsLanguageServer.scala:170)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.lang.Thread.run(Thread.java:840)

Do I need a copy of java in the source dir? As I'm sure that I have openjdk@21 on my mac as java --version shows 21 already.

To Reproduce Steps to reproduce the behavior(sample project + file which can be used to reproduce the issue with.)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Logs Please include the debug stack trace (if there is an error) and the content of Messages buffer with lsp-print-io set to t in case the bug is related to client->server communication.