Fork me on GitHub
Chad kennedy00:12:36

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:


hum, that's bad, sounds like clojure-lsp issue on wsl :thinking_face:

Chad kennedy01:12:20

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?


It doesn't look like a common issue, let try get some logs

Chad kennedy00:12:50

Dec 23, 2021 6:42:01 PM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: An error occurred while processing an incoming message.
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(
    at java.util.concurrent.Executors$
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$


Pasting the server logs would be more helpful. 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.

👍 1
Chad kennedy01:12:21

When I run Calva Diagnostics: Open Clojure-lsp Log File I get The clojure-lsp server is not running or has not finished intializing.


Yeah, that calva command won't work for this case :(


(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).


Only if you set clojure-lsp config log-path


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.

☝️ 1

I'm not sure though where the exceptions is happening, there is a chance being thown even before clojure-lsp check config settings

Chad kennedy01:12:04

I set clojure.trace.server to verbose as instructed in the troubleshooting section. Output above.


I think it'd be good to test if that happens for a non native clojure-lsp


You can download from latest release on clojure-lsp github


And set calva to use that downloaded clojure-lsp from a calva setting

Chad kennedy01:12:52

Kk. Thanks for all your help so far!

Chad kennedy01:12:43

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 --versionI 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

Chad kennedy01:12:46

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


@U02RVND2N59 I think I found the issue

🙌 1

in the initialize request, the rootURI is null, which is a must for clojure-lsp works properly


we need to know why vscode is sending that as null


maybe try older calvas to confirm that behavior happens


how are you opening vscode? are you opening a folder or a single file?

Chad kennedy02:12:01

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).

Chad kennedy02:12:18

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

Chad kennedy02:12:52

"rootUri": null, still shown at the top of that log though.


yeah, doesn't seem related, the issue seems to be the missing rootURI indeed


not sure what vscode does to get that, but usually it just pass the opened vscode worksapce proejct path

Chad kennedy02:12:45

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:


that's odd, AFAIK the repl should not be related with that rootURI param, any thoughts @U9A1RLFNV?

Chad kennedy02:12:52

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.

Chad kennedy02:12:51

But, Clojure Language Client window shows a non-null rootURI and appears to be working.


Good, so that was the issue indeed


we just need to know why that uri is being passed as null


also, we could at least improve clojure-lsp to not fail like that when rootURI is null and give a proper warning

Chad kennedy02:12:18

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.

Chad kennedy02:12:19

(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

Chad kennedy02:12:03

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!

gratitude 2
💜 2

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?

👍 1

@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.


Thanks for your responsiveness as well and your debugging efforts!

Chad kennedy00:12:50

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.


oh, i never thought of snippets. That's a good idea! Thanks

👍 1

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

👍 1

You could also write a babashka script to create files from a template babashka


I have the following namespace def:

(ns agold.cljip
  (:require [clojure.string :as str])
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?


Have you loaded the file first?


What steps do you take to start the repl when it doesn’t work?


Sorry, I misled you. Actual ns is:

(ns agold.cljip
  (:require [config.core :as e]
            [clojure.string :as str])
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])

(defn greet
  "Callable entry point to the application."
  (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)}))

  (greet nil)
  (str/lower-case "FOO")
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.


Merry Christmas to you too! 🎄


I cannot reproduce the issue. :thinking_face:


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!


My deps.edn:

{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.10.3"}
        yogthos/config {:mvn/version "1.1.9"}}
 {: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"}
                      {: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?


Ah, when I select both build and test, I can reproduce…


Yes, I just tried here, and it works if I deselect those. I thought I had to choose one. Thanks!


If I just select test, there’s no issue as well.


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!

😄 1
👍 1

@U0ETXRFEW Do you know why that alias causes that issue? Maybe it’s something with :ns-default :


You guys are amazing! Best support ever! Many, many thanks.

❤️ 1