This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-24
Channels
- # adventofcode (11)
- # asami (1)
- # babashka (9)
- # beginners (81)
- # calva (85)
- # circleci (4)
- # clojure (32)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-uk (2)
- # clojurescript (28)
- # cursive (5)
- # fulcro (3)
- # honeysql (1)
- # introduce-yourself (1)
- # jobs-discuss (1)
- # missionary (1)
- # off-topic (1)
- # other-languages (42)
- # re-frame (12)
- # releases (1)
- # shadow-cljs (1)
Hi all. Using Calva in Windows 10, connected to WSL. I opened the Getting Started REPL. I see "Initializing Clojure language features via clojure-lsp" spinning forever in the status bar. In the Clojure Language Client
window I see:
Anything I can do to help diagnose? Post some logs or anything? Is anyone else experiencing a similar issue, or is running in my configuration fairly rare?
Check troubleshooting: https://calva.io/clojure-lsp/
Dec 23, 2021 6:42:01 PM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: An error occurred while processing an incoming message.
java.lang.NullPointerException
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:279)
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:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Pasting the server logs would be more helpful. https://calva.io/clojure-lsp/#opening-the-server-log-file. To make it easier to find the issue, I have in the past opened the log file, deleted the contents, then performed the action that I wanted to see logs for.
CC @UKFSJSM38 (just CC’ing here since it’s a new thread). Let’s keep the convo going in this thread.
When I run Calva Diagnostics: Open Clojure-lsp Log File
I get The clojure-lsp server is not running or has not finished intializing.
(From main thread) > I can execute the code in hello_repl.clj, and go to definition works, for println at least. Just FYI, Calva uses the repl connect for evaluating code, and also for Go to Definition if a repl connection exists and returns a definition (otherwise it uses clojure-lsp for Go to Definition).
I think that command only uses info from a running clojure-lsp instance. So if you define your log-path in your clojure-lsp config, you’ll have an easier time finding it manually.
I'm not sure though where the exceptions is happening, there is a chance being thown even before clojure-lsp check config settings
I set clojure.trace.server to verbose as instructed in the troubleshooting section. Output above.
Kk. Thanks for all your help so far!
I've downloaded clojure-lsp.jar version 2021.12.20-00.36.56 into WSL and chmod 755 for it. When I run java -jar ./clojure-lsp.jar --version
I get
clojure-lsp 2021.12.20-00.36.56
clj-kondo 2021.12.19
I tried setting calva.clojureLspPath
to java -jar ./clojure-lsp.jar
but that didn't work (`Launching server using command java -jar /home/chad/clojure-lsp.jar failed.`). Then I noticed the text for that setting says "path to the clojure-lsp
native binary". Not sure where to specify the use of the non-native java library.@U02RVND2N59 there is the clojure-lsp.bat
you can download instead of the jar
Ok, that runs, in the sense that I don't get Launching server using command ... failed.
But I'm still getting the fireError
from the beginning of the thread.
I suspect the json sent by the client or the json sent by the server is wrong, causing clojure-lsp not parsing correctly
in the initialize request, the rootURI
is null, which is a must for clojure-lsp works properly
I've tried calva versions back to 2.0.199 wwith the same results. I open vs code in Windows, just by clicking the icon in the start menu. From there, I open a new wsl window (in vs code), then run the Calva getting started REPL (also in vs code).
If I go back to 2.0.177, I start getting different behavior where the REPL doesn't connect automatically. But I do see soemthing different in the Clojure Language Client
window. Example:
[Trace - 8:09:58 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "vscode-local:/c%3A/Users/Chad/AppData/Roaming/Code/User/globalStorage",
"type": 2
},
{
"uri": "vscode-userdata:/c%3A/Users/Chad/AppData/Roaming/Code/User/globalStorage",
"type": 2
}
]
}
"rootUri": null,
still shown at the top of that log though.
not sure what vscode does to get that, but usually it just pass the opened vscode worksapce proejct path
Making some progress. So, when you run "Calva: Fire up the "Getting Started" REPL, the rootUri is null. But if I close and re-open that temp folder manually, rootUri is no longer null. Got the idea from here: https://github.com/eclipse/xtext-core/issues/57
that's odd, AFAIK the repl should not be related with that rootURI param, any thoughts @U9A1RLFNV?
When I manually open the temp folder created when I ran "Calva: Fire up the "Getting Started" REPL
, the REPL is not connected, and I don't know how to make it connect. This could just be a beginner issue. Still learning the tool obviously.
But, Clojure Language Client
window shows a non-null rootURI
and appears to be working.
also, we could at least improve clojure-lsp to not fail like that when rootURI is null and give a proper warning
Ok. If, after opening the temp folder, I run "Calva: Fire up the "Getting Started"
REPL again, but tell it to use the existing temp folder, the I have a working REPL and a working lsp server.
From the issue 57 link above, it looks like this (rootUri being null) is because vscode wasn't opened to a particular folder. Could the command "Calva: Fire up the "Getting Started" REPL
be updated to create the temp folder and files, and then open the folder, instead of opening the individual files? That might fix it.
(Sorry I don't know enough Clojure yet to try out that fix myself. Hopefully soon!)
I think you did a good debugging! @U0ETXRFEW and @U9A1RLFNV will probably know better about that
BTW, I just wanna say how impressed I am by the level and responsiveness of support I've received here. I've been part of many different open source platforms and projects, and never seen anything this amazing. You guys are awesome!!!! I know it must be a lot of work, but it sure does make it an attractive platform to use!

We can't open a folder, only files. But we do know the folder uri. Maybe there is a way to give that to the lsp server when starting it?
@U02RVND2N59 Would you mind creating an issue describing the problem so we can track it? Stating the steps you took above that led to the issue would be great. It would be appreciated. We may be able to fix it by manually passing the root URI.
@U9A1RLFNV Sure thing. Issue is created: https://github.com/BetterThanTomorrow/calva/issues/1445
I can execute the code in hello_repl.clj, and go to definition works, for println at least.
Is it possible to setup templates for a project in calva, so if I create a new .clj file it will give me my template. e.g., I can setup a template like
(ns stuartstein777.rosalind.rna-to-protein
(:require [clojure.string :as str]
[clojure.set :as set))
I don’t believe so, but you may be able to do this with snippets. There may be extensions to help create and use snippets as well.
Although, I think you’d still have to create the file, then use a snippet within the file. I’m not sure if the file can be created with a snippet already in it.
yeah, i can at least create a snippet for this project WIth the same (:require)
form
I have the following namespace def:
(ns agold.cljip
(:require [clojure.string :as str])
(:gen-class))
But when I evaluate (str/lower-case "FOO") in Calva's repl, I get:
; Syntax error compiling at (src/agold/cljip.clj:19:3).
; No such namespace: str
But if I start a repl with clj, I can evaluate this form with no error. How do I troubleshoot this? Can I see the classpath Calva is using?Sorry, I misled you. Actual ns is:
(ns agold.cljip
(:require [config.core :as e]
[clojure.string :as str])
(:gen-class))
deps.edn containss:
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
yogthos/config {:mvn/version "1.1.9"}}
On loading and evaluating file, I get:
; Evaluating file: cljip.clj
; Syntax error (FileNotFoundException) compiling at (src/agold/cljip.clj:1:1).
; Could not locate config/core__init.class, config/core.clj or config/core.cljc on classpath.
; Evaluation of file cljip.clj failed: class clojure.lang.Compiler$CompilerException
But config-1.1.9.jar is in my .m2 repository. repl is started in Calva with deps.edn and build selected. Here is the relevant clause from deps.edn:
:build {:replace-deps {io.github.seancorfield/build-clj
{:git/tag "v0.6.3" :git/sha "9b8e09b"
;; since we're building an app uberjar, we do not
;; need deps-deploy for deployment:
:deps/root "slim"}}
The deps.edn file was created by Sean Corfield's "new" tool. I have always used lein until now. This is my first project with deps.edn, so maybe I'm not understanding something about loading dependencies.
Can you share the command and args used to create the project? I can try the same/similar project and see if I can reproduce.
Here's deps.edn:
:build {:replace-deps {io.github.seancorfield/build-clj
{:git/tag "v0.6.3" :git/sha "9b8e09b"
;; since we're building an app uberjar, we do not
;; need deps-deploy for deployment:
:deps/root "slim"}}
And here's the source file cljip:
(ns agold.cljip
(:require [config.core :as e]
[clojure.string :as str])
(:gen-class))
(defn greet
"Callable entry point to the application."
[data]
(println "conf key is: " (:API-KEY (e/load-env)))
(println "foo is" (str/lower-case "Foo"))
(println (str "Hello, " (or (:name data) "World") "!")))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(greet {:name (first args)}))
(comment
(greet nil)
(str/lower-case "FOO")
#_(config.core/load-env)
#_(e/load-env)
)
Created using clj -Tnew app :name agold/cljip
yogthos/config 1.1.9 subsequently added to deps edn.Thanks, and Merry Christmas! I'll be out for a while, but all help is much appreciated.
I created the project with clj -Tclj-new app :name agold/cljip
, and added yogthos/config to the deps.
And copied the same file contents from above and the file loads successfully. When I run (greet nil)
:
conf key is: nil
foo is foo
Hello, World!
nil
My deps.edn:
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
yogthos/config {:mvn/version "1.1.9"}}
:aliases
{:run-m {:main-opts ["-m" "agold.cljip"]}
:run-x {:ns-default agold.cljip
:exec-fn greet
:exec-args {:name "Clojure"}}
:build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.6.3" :git/sha "9b8e09b"
;; since we're building an app uberjar, we do not
;; need deps-deploy for deployment:
:deps/root "slim"}}
:ns-default build}
:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "48c3c67"}}}}}
@U0ETXRFEW Any idea what could be going wrong for @U2CR1J4UV?
Oh, to add more details, I used Calva’s jack-in command to start the repl, and did not select an alias.
Does that mean that after selecting deps.edn in the jack-in menu, you did not check either build or test?
Yes, I just tried here, and it works if I deselect those. I thought I had to choose one. Thanks!
No problem! I don’t know much about build-clj
, but it looks like the :build alias is meant for building an uberjar, so when starting a repl for general development, I don’t think you need to select that alias. I’m not sure why it causes that issue though.
Thanks again for the enlightenment. I need to understand the build-clj tool better, but at least I can drink my eggnog tonight without this problem nagging at me!
@U0ETXRFEW Do you know why that alias causes that issue? Maybe it’s something with :ns-default
: https://clojure.org/reference/deps_and_cli#_tool_usage.