Fork me on GitHub
Jakub Holý (HolyJak)09:08:52

Hello! I see in the logs > ERROR Could not load project cache from '/path/2/fulcro-rad-demo/.lsp/sqlite.db But this is a new project and I have not used LSP there before. So perhaps it should be just info/warning, not error?


yeah, probably a warn for this would be better

Jakub Holý (HolyJak)09:08:26

I also get > INFO [clojure-lsp.crawler:21] - Finding classpath via clojure -Spath > ERROR [clojure-lsp.crawler:40] - Error while looking up classpath info in .../fulcro-rad-demo Cannot run program "clojure" (in directory ".../fulcro-rad-demo"): error=2, No such file or directory Yet, in the shell, it is just fine:

❯ which clojure
Does LSP have a different path? How to verify/fix that?


it seems related with your project root :thinking_face:


it didn't find the path ../fulcro-rad-demo


is your project a lein one? a shadow-cljs one? both?

Jakub Holý (HolyJak)13:08:35

(I run LSP via Cursive and its LSP Support plugin)


let me test it

❤️ 3

Everything worked as expected with emacs, I suspect you LSP plugin sent a wrong project root ../fulcro-rad-demo instead of /absolute/path/to/fulcro-rad-demo


(I added a log on clojure-lsp server to log the project-root to easily find issues like that)

❤️ 3
Jakub Holý (HolyJak)13:08:11

cool, thanks! how can I get the version with the log added?


only on next release or building manually on master, but there are other ways to get that


As mentioned, every client should provide the client<->server log


check the LSP intellij plugin on how to get that


on that log, it should mention the initialized request with the project-root-uri

Jakub Holý (HolyJak)13:08:39

I have clojure-lsp log file, if that is what you mean

Jakub Holý (HolyJak)13:08:40

I just tried again after restarting LSP and get the same error, this time with abs. paths > Error while looking up classpath info in /Users/me/Projects/external/fulcro-all/fulcro-rad-demo Cannot run program "clojure" (in directory "/Users/me/Projects/external/fulcro-all/fulcro-rad-demo"): error=2, No such file or directory (+ the same error for npx )


on, I think somewhere else using LSP plugin reported the same issue


it was related with Intellij/LSP plugin not finding clojure/npx on your PATH

Jakub Holý (HolyJak)14:08:29

quite possible, since clojure is under /usr/local/... and npx is in /Users/me/.nvm/versions/node/v10.24.1/bin/npx


yeah, probably the shell that LSP plugin is using to launch clojure-lsp doesn't have there commands on PATH

💯 3
Jakub Holý (HolyJak)14:08:10

Perhaps print $PATH when you cannot find the executable?


oh, good finding


it's not easy to know if the executable is not in the PATH


I think we already log this to both clojure-lsp server log and client so checking the exception seems good enough, is just that the java exception is not clear enough for shell commands


Does LSP handle ClojureScript’s “Clojure Namespace Aliasing” for things like Goto Definition and Show Doc String?


Not sure if it is directly that, or related to the reader macro for language conditionals, as macros in a .cljc file guarded with a #?(:clj also don’t show anything when trying to Goto Definition or Show Doc String


If I understood correctly, you are asking if clojure-lsp will go to cljs.test even if you required clojure.test in a cljs project?


Trying to understand which things I can expect to lookup vs not, and I think that is what I am seeing at least


wasn’t sure if that was a known thing, or if something possibly related to setup


other CLJ based macros in ClojureScript also seem to behave similar, but not sure if that is related or not


This definitely doesn't works with clojure-lsp, unless clj-kondo return the cljs.test analysis in the place of clojure.test


feel free to open an issue for that, but I think we would need to do some improvements on clj-kondo as well, right @U04V15CAJ?


yeah, repro would be nice


As far as I can understand, reading that docs is that doesn't need to be a cljc file


:thumbsup: Will see about getting something together for a baseline to reproduce, just wanted to make sure I was on the right track and understanding what I am thinking is happening. 😉

👍 6

Not sure if you want a full basic project setup, or just the file, but if the file, I pasted it above


the async go and <! references don’t show up with the help, regardless of which reference is used…


I can add a basic skeleton project out on github if that helps


yeah, that would help :)


just pushed some screenshots up as well


if there are any logs or any other things that might be helpful, I can push them up there too


thank you!


nice! I'll have a look

Jakub Holý (HolyJak)16:08:48

How does clojure-lsp communicate with an editor? Do they use stdin+stdout, or...?


the LSP client (editor) is responsible for spawning the LSP server process, not as a daemon, but as a process, and they communicate via stdin/out


sending and receiving LSP JSON

Jakub Holý (HolyJak)16:08:40

ok, thx! Now I understand I must not mess with the stdin/out 🙂


haha yes, you can easily try clojure-lsp from your terminal to understand that if you want



👍 3

and then it'll start to listen for json + content-length

Jakub Holý (HolyJak)16:08:59

My log file contains only

[clojure-lsp.server:419] - Starting server...
[clojure-lsp.nrepl:20] - ====== LSP nrepl server started on port 65034
[clojure-lsp.server:304] - Initializing...
It has run for 4 minutes now. Is it possible it got stuck somehow? I execute it from an editor via this script
#!/bin/bash -l
eval "$(direnv hook bash)" > /dev/null
exec /usr/local/bin/clojure-lsp #--verbose


no, what happens is:


after that Initializing.. log, clojure-lsp checks for the :log-path config and change log to log to that path


you probably have something setted for :log-path right?

Jakub Holý (HolyJak)16:08:56

OMG, you are right, and I completely forgot


yeah, maybe we can fix that somehow in the future, is not that easy though

Jakub Holý (HolyJak)16:08:32

Ok, I removed the setting and now the log file also has

[clojure-lsp.source-paths:135] - Automatically resolved source-paths from project.clj: #{"src" "src/main/clojure" "dev" "test" "src/test/clojure"}
but according to ps , lsp is not running anymore


:thinking_face: odd, it should not stop/finish unless a huge exception

Jakub Holý (HolyJak)17:08:20

I tried again and I see a number of clojure-lsp runs, one by one. From the log:

T17:01:15.970Z [clojure-lsp.server:419] - Starting server...
T17:01:15.990Z [clojure-lsp.nrepl:20] - ====== LSP nrepl server started on port 65034
T17:01:15.997Z [clojure-lsp.server:304] - Initializing...
T17:01:16.021Z [clojure-lsp.source-paths:135] - Automatically resolved source-paths from project.clj: #{"src" "src/main/clojure" "dev" "test" "src/test/clojure"}
T17:01:10.953Z [clojure-lsp.server:419] - Starting server...
T17:01:10.975Z [clojure-lsp.nrepl:20] - ====== LSP nrepl server started on port 65034
T17:01:10.983Z [clojure-lsp.server:304] - Initializing...
T17:01:11.009Z [clojure-lsp.source-paths:135] - Automatically resolved source-paths from project.clj: #{"src" "src/main/clojure" "dev" "test" "src/test/clojure"}
T17:01:05.938Z [clojure-lsp.server:419] - Starting server...
T17:01:05.961Z [clojure-lsp.nrepl:20] - ====== LSP nrepl server started on port 65034
T17:01:05.968Z [clojure-lsp.server:304] - Initializing...
T17:01:05.997Z [clojure-lsp.source-paths:135] - Automatically resolved source-paths from project.clj: #{"src" "src/main/clojure" "dev" "test" "src/test/clojure"}
T17:00:55.896Z [clojure-lsp.server:419] - Starting server...
T17:00:55.924Z [clojure-lsp.nrepl:20] - ====== LSP nrepl server started on port 65034
T17:00:55.936Z [clojure-lsp.server:304] - Initializing...

Jakub Holý (HolyJak)17:08:16

it seems the IntelliJ LSP plugin is simply cursed 😿


I already saw people setupping and running correctly, probably is not well documented what it's needed to do


I can try to setup that on the weekend


meanwhile, there are somethings you may debug:


• any bad exceptions goes to the stderr, but depending on the exception, if not critical, goes to server log

Jakub Holý (HolyJak)17:08:20

the server log has nothing and lsp/log/clojure_err_20210826.log as well as _out_ are empty


what is your clojure-lsp --version

Jakub Holý (HolyJak)17:08:55

clojure-lsp 2021.08.24-14.41.56 clj-kondo 2021.08.07-SNAPSHOT


alright, let's step back and check if clojure-lsp is ok


we will try to send the initialize request via CLI


so you will need to do something like we do for clojure-lsp integration-tests

Jakub Holý (HolyJak)17:08:22

Hm, it works on another project. In failing one I see a WARN log from the intellij LSP plugin about invalid url for a maven dependency I have, it is possible despite being just warning that the plugin rashes


first, what's your project absolute path?


yes, probably


You can try on your terminal:

echo "Content-Length: 168

" | ./clojure-lsp
remeber to update both project root and Content Lenght of the json

Jakub Holý (HolyJak)17:08:20

Ok! I have made some progress. I have got my wrapper script to work and use it to set PATH so that lsp finds both clojure and npx. Thus it stopped popping errors in intellij but still IntelliJ times out, perhaps because the analysis takes too long. Last log is > Analyzing 1/4 batch paths with clj-kondo... from 2 minutes ago. Perhaps it just takes a while the first time?


Oh, some user said that he needed to increase the timeout for the LSP plugin


but yeah, the very first time takes longer because it scans whole classpath, next startups should be few seconds


I think there is a option to increase the timeout via the plugin

Jakub Holý (HolyJak)17:08:57

Ok, will try that. The "Analyzing 1/4 batch paths with clj-kondo" flog is the last one and there is no clojure-lsp process running, don't know whether it died itself or the intellij plugin killed it upon timeout

Jakub Holý (HolyJak)17:08:16

Yep , it seems indeed the plugin kills clojure-lsp if it takes over its timeout

Jakub Holý (HolyJak)17:08:09

Ok, now it works, after I increased the timeout and restarted intellij (it took about 1min for clojure-lsp to do its job)

Jakub Holý (HolyJak)17:08:36

Awesome, now it works on the other prj as well. So the key was to increase the timeout sufficiently

Jakub Holý (HolyJak)17:08:48

thx a lot for your invaluable help!!!


Nice! I really don't know why this plugin has a timeout like that, but we should surely add that to the clojure-lsp client intellij section docs, willing to open a PR later ?

Jakub Holý (HolyJak)19:08:48

Perhaps LSP Support has such a short timeout for Init because it expects it to be short, not to do the whole analysis thing. Perhaps it thinks the analysis is just started and runs async, in the background?


yeah, but a lot of features may not work if the analysis scan didn't finish yet, that's why we wait

👍 3

even kondo diagnostics depend on that scan