Fork me on GitHub
#calva
<
2021-09-25
>
paulbutcher16:09:39

I’ve just returned to a Clojure project which has been lying fallow for a while. When I start VSCode, the “Initializing Clojure language features via clojure-lsp” never goes away. I’ve followed the troubleshooting instructions on the Calva website, and sure enough, I see an error in the Clojure Language Client channel, but I’m not sure what it’s telling me. Suggestions gratefully received (thanks in advance):

[Trace - 17:02:01] Sending request 'initialize - (0)'.
Params: {
    "processId": 30674,
    "clientInfo": {
        "name": "vscode",
        "version": "1.60.2"
    },
    "rootPath": "/Users/paulbutcher/Projects/raceandimprove/race-and-improve",
    "rootUri": "file:///Users/paulbutcher/Projects/raceandimprove/race-and-improve",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional"
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                }
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": false,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                }
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    }
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    }
                },
                "contextSupport": true
            },
            "definition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "references": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "implementation": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            },
            "declaration": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "selectionRange": {
                "dynamicRegistration": true
            }
        },
        "window": {
            "workDoneProgress": true
        }
    },
    "initializationOptions": {
        "dependency-scheme": "jar",
        "auto-add-ns-to-new-files?": true,
        "document-formatting?": false,
        "document-range-formatting?": false,
        "keep-require-at-start?": true
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///Users/paulbutcher/Projects/raceandimprove/race-and-improve",
            "name": "race-and-improve"
        }
    ]
}


Sep 25, 2021 5:02: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:567)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

ericdallo16:09:49

that's exception is no good 😅 But it seems it's not the full stack, could you try get the full stack from clojure-lsp server log?

paulbutcher15:09:57

Thanks @UKFSJSM38. Sorry for the delay, but I’ve just got back to this. This is what I see in the clojure-lsp server log:

2021-09-26T14:58:59.026Z Pauls-16in-MBP ERROR [clojure-lsp.server:?] - 
                                 com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine            PosixJavaThreads.java:  192
                                             com.oracle.svm.core.thread.JavaThreads.threadStartRoutine                 JavaThreads.java:  567
                                                                                  java.lang.Thread.run                      Thread.java:  829
                                                    java.util.concurrent.ThreadPoolExecutor$Worker.run          ThreadPoolExecutor.java:  628
                                                     java.util.concurrent.ThreadPoolExecutor.runWorker          ThreadPoolExecutor.java: 1128
                                                                   java.util.concurrent.FutureTask.run                  FutureTask.java:  264
                                                   java.util.concurrent.Executors$RunnableAdapter.call                   Executors.java:  515
                                         org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run  ConcurrentMessageProcessor.java:  113
                                           org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen       StreamMessageProducer.java:   94
                                    org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage       StreamMessageProducer.java:  194
                                                      org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume              RemoteEndpoint.java:  190
                                                org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest              RemoteEndpoint.java:  261
                                            org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request             GenericEndpoint.java:  120
                                      org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0             GenericEndpoint.java:   65
                                                                                                   ...                                       
clojure_lsp.server.proxy$clojure_lsp.ClojureExtensions$ExtraMethods$LanguageServer$4129860f.initialize                                       
                                                                              clojure-lsp.server/fn/fn                       server.clj:  301
                                                                       clojure-lsp.handlers/initialize                     handlers.clj:   49
                                                                clojure-lsp.crawler/initialize-project                      crawler.clj:  186
                                                                                   clojure.core/update                         core.clj: 6185
                                                                               clojure.core/partial/fn                         core.clj: 2635
                                                         clojure-lsp.source-paths/process-source-paths                 source_paths.clj:  131
                                                         clojure-lsp.source-paths/resolve-source-paths                 source_paths.clj:  126
                                              clojure-lsp.source-paths/resolve-source-paths-from-files                 source_paths.clj:   92
                                                                     clojure-lsp.parser/lein-zloc->edn                       parser.clj:  112
                                                                                rewrite-clj.zip/remove                         zip.cljc:  569
                                                                        rewrite-clj.zip.removez/remove                     removez.cljc:   57
java.lang.AssertionError: Assert failed: zloc

2021-09-26T14:58:59.028Z Pauls-16in-MBP DEBUG [clojure-lsp.server:?] - :initialize 21ms

paulbutcher15:09:41

The significant line seems to be:

java.lang.AssertionError: Assert failed: zloc

paulbutcher15:09:50

But I’m not sure what that’s telling me?

ericdallo15:09:13

@U5KAD4W2E it seems the file you have opened has not valid clojure code, even with this exception the server should start without any issues

paulbutcher15:09:22

You mean the file that I’ve opened in VSCode?

ericdallo15:09:52

could you try with a simple repro where I can see the code as well? a repo on github would help a lot

paulbutcher15:09:13

So I don’t have a file open at all. All I’ve done is open VSCode on a directory containing a Clojure project.

paulbutcher15:09:20

Are you suggesting that one of the files within the project might be causing the problem?

ericdallo15:09:58

this expection happens when we can't parse the code but again, it should not block clojure-lsp from initializing and working

ericdallo15:09:07

please test in a simple repro where I can try it myself

ericdallo15:09:19

also, make sure you have latest clojure-lsp

paulbutcher15:09:44

I thought that Calva had its own clojure-lsp bundled?

ericdallo15:09:20

it has, not sure it uses always the latest

ericdallo15:09:26

double check the Calva settings

paulbutcher15:09:48

The documentation here suggests that it does use latest (unless configured otherwise, which I haven’t done): https://calva.io/clojure-lsp/

paulbutcher15:09:11

How would I check which version is being used?

ericdallo15:09:40

good question, I don't know, probably it's using latest

paulbutcher15:09:38

OK, so I’m going to create an empty Clojure project and confirm that Calva/clojure-lsp startup OK with that.

ericdallo15:09:54

@U5KAD4W2E I just checked again the exception and found that the issue is when resolving the source-paths

paulbutcher15:09:57

Assuming that that does work, I’ll see if I can create a cutdown version of my project which reproduces the problem

ericdallo15:09:29

what kind of project it's yours? project.clj, deps.edn ?

paulbutcher15:09:13

This is my deps.edn:

{:deps {org.clojure/clojure {:mvn/version "1.10.3"}
        org.clojure/clojurescript {:mvn/version "1.10.879"}
        org.clojure/spec.alpha {:mvn/version "0.2.194"}

        amazonica/amazonica {:mvn/version "0.3.156"}
        binaryage/dirac {:mvn/version "1.7.2"}
        binaryage/oops {:mvn/version "0.7.1"}
        clj-http/clj-http {:mvn/version "3.12.3"}
        cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
        com.bhauman/figwheel-main {:mvn/version "0.2.14"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
        day8.re-frame/http-fx {:mvn/version "0.2.3"}
        day8.re-frame/tracing {:mvn/version "0.6.2"}
        day8.re-frame/re-frame-10x {:mvn/version "1.1.13"}
        funcool/promesa {:mvn/version "6.0.2"}
        io.sentry/sentry-clj {:mvn/version "5.0.152"}
        nrepl/nrepl {:mvn/version "0.8.3"}
        org.slf4j/slf4j-simple {:mvn/version "1.7.32"}
        ovotech/ring-jwt {:mvn/version "2.2.1"}
        re-frame/re-frame {:mvn/version "1.2.0"}
        reagent/reagent {:mvn/version "1.1.0", :exclusions [cljsjs/react
                                                            cljsjs/react-dom
                                                            cljsjs/react-dom-server]}
        metosin/reitit {:mvn/version "0.5.15"}
        ring/ring-defaults {:mvn/version "0.3.3"}
        ring/ring-jetty-adapter {:mvn/version "1.9.4"}
        ring/ring-json {:mvn/version "0.5.1"}
        testdouble/clojurescript.csv {:mvn/version "0.5.1"}
        tick/tick {:mvn/version "0.5.0-RC2"}}

 :paths ["src/cljs" "src/cljc" "src/clj" "resources"]

 :aliases {:dev-ui {:extra-paths ["src/dirac" "test/cljs" "src/dev"]
                    :main-opts ["-m" "dirac-figmain.repl"]}
                    ; :main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]} ; Normal figwheel build
           :prod-ui {:extra-paths ["src/prod"]
                     :main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "prod"]}
           :test-ui {:extra-paths ["test/cljs"]
                     :main-opts ["-m" "figwheel.main" "-co" "test.cljs.edn" "-m" race-and-improve.test-runner]}

           :dev {:extra-paths ["src/dev"]}
           :prod {:extra-paths ["src/prod"]}
           :serve {:main-opts ["-m" "race-and-improve.core"]}
           :test {:extra-paths ["test/clj"]
                  :extra-deps {com.cognitect/test-runner {:git/url ""
                                                         :sha "dd6da11611eeb87f08780a30ac8ea6012d4c05ce"}}
                  :main-opts ["-m" "cognitect.test-runner"]}
           
           :depstar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
                     :ns-default hf.depstar
                     :exec-args {}}}}

ericdallo15:09:08

Alright, I'll take a look, just to make sure, this is the only project type right? do you have a bb.edn or something as well?

paulbutcher15:09:08

Its the only project type. There are some additional Figwheel edn config files (although I don’t imagine that they should make a difference?)

paulbutcher15:09:27

FYI, I can confirm that clojure-lsp starts successfully in a “bare bones” Clojure project

paulbutcher15:09:33

And it tells me:

clojure-lsp version used: 2021.09.13-22.25.35
clj-kondo version used: 2021.08.07-SNAPSHOT

paulbutcher15:09:30

Any sign of a “smoking gun” in that deps.edn?

ericdallo15:09:05

not really, I used that deps.edn on a sample project of mine and everything started :thinking_face:

paulbutcher15:09:19

OK, let me start cutting the project down and see if I can create a minimal reproduction.

ericdallo15:09:09

that would help, probably it's a clojure-lsp bug or corner case it's not handling well, but we need a sample project which repro the issue so we can debug further more and understand what's wrong

paulbutcher15:09:30

On it - will let you know when I’ve got something 👍

👍 1
paulbutcher15:09:01

Ah! Found it!

👀 1
paulbutcher15:09:47

I lied when I said that there was no other project file. There is a project.clj. But it looks like this:

; Unused - only here because the Heroku Clojure buildpack insists upon project.clj being present

paulbutcher15:09:11

Delete that file and everything works fine. I guess I need to have something minimal in there like:

{}

ericdallo15:09:06

yes, that's not a clj file if you leave only the comment

ericdallo15:09:15

you could just change to:

; Unused - only here because the Heroku Clojure buildpack insists upon project.clj being present
{}

paulbutcher15:09:32

Just tried that and I get the same error

paulbutcher15:09:40

So it looks like that’s still too minimal

ericdallo15:09:41

even so, probably a exception would happen on clojure-lsp because it doesn't expects a missing defproject on project.clj

ericdallo15:09:05

clojure-lsp should safely parse that

ericdallo15:09:10

I'll make a fix for next release

ericdallo15:09:42

for now, you can probably set :source-paths setting or just delete that file if you can do that

paulbutcher15:09:55

Cool, thanks! Would it be helpful for me to raise a bug on the clojure-lsp project? Or happy to leave you to do it as you understand it much better than I do!

ericdallo15:09:12

please raise a bug so I can prioritize

paulbutcher15:09:24

I can’t delete it, sadly: even though it’s unused, Heroku’s Clojure build pack insists upon it being there 😞

👍 1
ericdallo15:09:44

Good to know there is this corner case

paulbutcher15:09:46

Will do. And thanks for your help!

bringe01:09:57

@U5KAD4W2E Just so you know, Calva ouputs the version of clojure-lsp it’s configured to use in the “Calva says” channel. For example: > clojure-lsp version configured: latest When the clojure-lsp server actually starts up, you can use the Clojure-lsp Server Info command, as well.

👍 1
paulbutcher12:09:19

Thanks @U9A1RLFNV. I noticed that once it actually started: my problem was that it wasn’t starting at all and didn’t get to that point :rolling_on_the_floor_laughing:

bringe00:09:16

Right, hence my note about when it actually start up 😄. I think the first info in that channel I mentioned will show whether it starts or not.

manas_marthi18:09:32

How to fix broken indentation

pez19:09:14

cljfmt does not pack spaces between forms, afaik. You’ll have to make it (< px (+ manually, I think.

pez19:09:54

Same with single empty lines (I think).

manas_marthi05:09:02

Ok tx. Is there anything in Emacs or spacemacs?

pez07:09:36

You can probably get zprint to clean thate whitespace up.

manas_marthi18:09:29

Hitting tab or alt tab l did not repack and reformat the entire form. Neither did control k control f