clojure-lsp / clojure-lsp-intellij

Intellij Plugin for Clojure & ClojureScript development via Language Server (LSP) made in Clojure
https://clojure-lsp.io
MIT License
76 stars 5 forks source link

classpath failed: lein/clojure not found in PATH #26

Closed loganrudd closed 4 months ago

loganrudd commented 8 months ago

I have mac m1 with Ventura 13.6. I installed the plugin in intelliJ, but it would error out when trying to initialize with the error:

clojure lsp classpath lookup failed when running clojure` lsp error: cannot run program "lein" (in directory ...): error=2 no such file or directory

But the directory does exist. After some googling I installed clojure-lsp with brew: arch -arm64 brew install clojure-lsp/brew/clojure-lsp-native

and restarted IDE, but when trying to initialize I get the following IntelliJ IDE Internal error:

java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "clojure.lang.IFn.invoke(Object, Object)" is null at com.github.clojure_lsp.intellij.extension.Formatting.canFormat(Unknown Source) at com.intellij.formatting.service.FormattingServiceUtil.lambda$findService$0(FormattingServiceUtil.java:28) at com.intellij.util.containers.ContainerUtil.find(ContainerUtil.java:872) at com.intellij.util.containers.ContainerUtil.find(ContainerUtil.java:856) at com.intellij.formatting.service.FormattingServiceUtil.findService(FormattingServiceUtil.java:26) at com.intellij.codeInspection.incorrectFormatting.FormattingChangesKt.detectFormattingChanges(FormattingChanges.kt:53) at com.intellij.formatting.visualLayer.VisualFormattingLayerServiceImpl.collectVisualFormattingLayerElements$lambda$10(VisualFormattingLayerServiceImpl.kt:67) at com.intellij.psi.codeStyle.CodeStyleSettingsManager.runWithLocalSettings(CodeStyleSettingsManager.java:91) at com.intellij.application.options.CodeStyle.runWithLocalSettings(CodeStyle.java:314) at com.intellij.formatting.visualLayer.VisualFormattingLayerServiceImpl.collectVisualFormattingLayerElements(VisualFormattingLayerServiceImpl.kt:65) at com.intellij.formatting.visualLayer.VisualFormattingLayerHighlightingPass.doCollectInformation(VisualFormattingLayerHighlightingPass.kt:37) at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:57) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:390) at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.runWithSpanIgnoreThrows(trace.kt:77) at com.intellij.platform.diagnostic.telemetry.helpers.TraceUtil.runWithSpanThrows(TraceUtil.java:24) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:386) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1133) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$3(PassExecutorService.java:377) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:376) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:352) at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:201) at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:207) at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:350) at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:190) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

ericdallo commented 8 months ago

Hey, clojrue-lsp-intellij doesn't require to install clojure-lsp, it's shipped with clojure-lsp built-in. The error you faced is something that I'm seeing happen for users that have lein or clojrue installed via brew, and it's not in the PATH that intellij uses... One workaround, until we find a proper fix, is to spawn intellij from a terminal that has lein in the PATH env.

ericdallo commented 8 months ago

I found that It's really messed up how things work for mac brew + intellij, I found that intellij has a whole class to handle those corner cases and the comment pretty describes your issue.

I discovered through this issue that there are ways to change that or check on intellij via the Preferences Tools Terminal, may you can double check that?

ericdallo commented 4 months ago

Folks, finally, this bug should be fixed by #34, now following all other editors standard, the plugin downloads automatically clojure-lsp process and spawn it instead of using clojure-lsp as a lib, it should not change anything to the final user, but it should fix this issue and others. Available on 2.0.0 version.