This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-17
Channels
- # announcements (1)
- # aws (7)
- # babashka (5)
- # calva (56)
- # cider (13)
- # clj-commons (1)
- # clj-kondo (12)
- # clj-yaml (35)
- # clojure (84)
- # clojure-europe (93)
- # clojure-sg (2)
- # clojure-uk (1)
- # clojurescript (10)
- # conjure (37)
- # core-typed (1)
- # cursive (31)
- # duct (1)
- # figwheel-main (4)
- # fulcro (2)
- # holy-lambda (2)
- # humbleui (3)
- # membrane (118)
- # off-topic (46)
- # pathom (8)
- # podcasts-discuss (5)
- # releases (2)
- # rewrite-clj (13)
- # sci (27)
- # shadow-cljs (17)
- # tools-deps (12)
I work in a project where the repo root is not the lein project root, like so:
- reporoot
- src (I don't know yet, why this exists)
- code (project is started inside here with lein dev)
- project.clj
When I open the folder reporoot
I don't get any IDE goodies like code navigation from Calva/Clojure-LSP, but it works fine when I open the folder code
. As expected, Clojure-lsp Server Info
command shows an empty classpath
vector when opening reporoot
but a correctly populated one when opening code
folder.
What I tried:
1. Setting reporoot/.lsp/config.edn
:project-path
to code/project.clj
results in warning that project.clj
could not be located
2. Setting :project-path
to code
results in errors (as expected from reading Clojure-lsp Docs)
3. Trying to cd
into code
before lein classpath
is called by changing :classpath-cmd
to [ "cd" "code" "&&" "lein" "classpath" ]
, because the warning from try number 1. suggests to me that Clojure-lsp calls lein classpath
from reporoot
instead of code
4. Also some tries changing :source-paths
in config.end
to include code/src
and also some changes to :source-paths
in code/project.clj
that didn't work out.
Is there some way to call lein classpath
from inside a subfolder of reporoot
(if indeed that is the problem)?Addendum: This is not urgent so enjoy your weekends if you can 🙂
:thinking_face:
I don't use Lein. But for a tools.deps project:
If I make an empty folder folder
(optionally adding an empty deps.edn
in folder
), copy some existing project project
into folder
, and then open folder
in Code:
1. I get all the expected behavior from Calva in files inside project
.
2. If I run Jack-In
, I am presented with a menu to choose to run Jack-In
on either /path/to/folder
or path/to/folder/project
.
Hmmm. I don't get any clojure-lsp help regardless if I have a tools.deps or Leiningen project in a sub folder of the opened root.
It could also be that we differ on ”all the expected behavior” 😃 Can you navigate to any clojure core stuff?
I can make tools.deps work for me if I put a this deps.edn
in reporoot
:
{:deps {sub-proj/sub-proj {:local/root "sub-tools-deps-project"}}}
Hmmm, now it works without a deps.edn
file. And I get navigation in a Leiningen sub-project as well...
Very strange. Especially this with that at first it didn't work, then it ”works”. Putting that into quotes, because clojure-lsp server-info reports a classpath of []
if I don't have a deps.edn
file. And will only get the correct classpath for the tools.deps project if I specifiy the local/root of the sub project. For the Leiningen sub project I have no clue how to make it work. Probably we need help with getting the clojure-lsp settings right. Ping @UKFSJSM38
clojure-lsp project itself is a example of a mono-repo deps project which works great, but deps allow that and make it easy with local/root, lein makes that harder.
I don't know what setting is project-path
you mentioned @ULA8H51LP, maybe you could provide a sample repro that doesn't work for you so we can try it as well?
Not sure what you mean by "navigate to" clojure core stuff. Must be a feature I don't know about? I do get a popup of the docs when I hover over a core function symbol.
> If I run Jack-In
, I am presented with a menu to choose to run Jack-In
on either /path/to/folder
or path/to/folder/project
.
That behavior is identical to with what I get, thanks for trying it out!
> Hmmm, now it works without a deps.edn
file. And I get navigation in a Leiningen sub-project as well...
Strange: It worked once for me but then I tried it again and it didn't.
> I don't know what setting is project-path
you mentioned @ULA8H51LP, maybe you could provide a sample repro that doesn't work for you so we can try it as well?
With project-path
I meant the project-specs
setting that can be configured with a .lsp/config.edn
file (https://clojure-lsp.io/settings/#classpath-scan)
The project public on Github but I just started working there 2 days ago and check with them if I can share it. If they rather I don't I try to create a repro. Thanks for all your help!
From your link:
> Note that clojure-lsp will make this scan to save the cache when:
> • The project has no cache (`.lsp/.cache`)
> • The project deps file (`project.clj` for example) changed.
> • The clj-kondo config has changed.
Perhaps LSP is not scanning for classpath because no trigger to indicate cache is out of date? What if you just delete reporoot/.lsp/cache
and try again?
@U90R0EPHA you thought makes sense, but we search for specific data in the cache here: https://github.com/clojure-lsp/clojure-lsp/blob/master/lib/src/clojure_lsp/crawler.clj#L198, so it's hard to be a corrupted cache, even so, worth the try
That didn't work either, here is a small repro: https://github.com/MTrost/reporoot
I can share the bigger project too but the repro worked so made more sense to share that.
But don't feel any urgency to fix this, I can work with just opening the code
folder for.
Thanks again for all the help!
@ULA8H51LP answering your question, lein does not support running from a different dir which is bad, but you can https://stackoverflow.com/questions/34078811/how-to-run-lein-from-another-directory-without-cd-to-project-dir, even so, there are other clojure-lsp features that rely on :project-root-uri
to work properly, which is something client(Calva) sends, using the current opened dir IIRC. Fixing the classpath command would help but would be a workaround, the best would be if Calva allows users to send a different project-root-uri during LSP initialize
request, lsp-mode (Emacs), for example allows that.
Will do!
I just tried it. (And got reminded that we've been trying it before.) VS Code won't allow it, whatever I send, VS Code will use the workspace root. I think our options here are:
1. Send the project-root-uri
in some non-standard way
2. Not support this use case
That's a bumber 😄 Issue is here, feel free to close again: https://github.com/BetterThanTomorrow/calva/issues/1866
I found a workaround, using VS Code Workspaces. I updated the issue with it. Please see if it works for you, @ULA8H51LP.
🎉🎉🎉 Works like a charm, thank you so much!
Awesome! Would you like to provide a PR adding that workaround to http://calva.io? I think it could go onto the general clojure-lsp page as well as get cross referenced from the page about workspace layouts.
I can of course do this myself, since I have things set up. But it is more fun with a contribution. 😃
yeah sure I give it a try!
Great! Please direct this one to dev
(we usually direct doc changes to published
) because it would be good with a changelog entry going with it that points to the issue you created.
:thumbsup: Should get to it later in the day
Here you go! Thanks again for the support to all of you! And for Calva, and for Clojure-LSP!

Calva's command "Toggle the REPL connection" doesn't complain, but the prompt still says clj:user. I had started the Clojure process with Calva's jack-in -> Leiningen+Shadow. For the most part, everything went fine, but there was a remark "Failed starting cljs repl for build: :app. Is the build running and connected?". (That's the right build keyword.) By "connected" is it referring to the browser? At that exact moment, the browser was not open. I subsequently opened the browser to the page served by Shadow's dev http. Shadow's "npx shadow-cljs cljs-repl :app" REPL works. Can Calva also connect? The symptom looks similar to https://github.com/BetterThanTomorrow/calva/issues/1285 but I am trying with Leiningen+Shadow, not deps.edn.
@U0ETXRFEW Any ideas here? You’re more familiar with this area of Calva.
Oh, thanks for the heads-up, @U9A1RLFNV. I had missed this one.
That's a confusing error message: ”Is the build running and connected?” because it doesn't need to be running or connected for the cljs REPL to start. I should reword that.
@U0HG4EHMH I think you might run into a Leiningen issue there, where it doesn't pick up the nrepl middleware configuration from the command line. You'll need to configure that in project.clj
. See https://calva.io/connect/#leiningen-shadow-cljs-middleware-issue
Hello all, After start with VSCODE in Clojure project, I'm getting this: [Error - 20:45:32] Server initialization failed. Message: Internal error Code: -32603 [object Object] [Error - 20:45:32] Clojure Language Client client: couldn't create connection to server. Message: Internal error Code: -32603 In WSL is ok, only problem with Windows 11
so it's not being able to download clojure-lsp for some reason, as a workaround while Calva maintainers don't take a look, you could point to a clojure-lsp manually downloaded
you can download latest clojure-lsp https://github.com/clojure-lsp/clojure-lsp/releases/tag/2022.09.01-15.27.31
@U0YJJPFRA See here if you need more info: https://calva.io/clojure-lsp/#using-a-custom-clojure-lsp.