Fork me on GitHub
Tao Lin03:12:35

Calva isn't evaluating for me. I'm using WSL2, and my project uses legacy figwheel (lein reagent template). I get "jack in done", but whenever I try to evaluate something, nothing happens. When I hover code, it says "loading". I tried a regular clojure lein project as well, and the same thing happened. Calva used to work on my system a few months ago, but now it doesn't.


Hi! I'm trying to transition from my old, tired Mac to a new shiny desktop that is running windows. I'm trying to follow the instructions to get a luminus project running in VSCode. I created a luminus project with lein new luminus box2box +re-frame +postgres +shadow-cljs and then from VSCode did the C-A-C C-A-J thing and selected Server + Client. In the output.calva-repl window I get the following exception:


Not sure where to go from here - I can't seem to get to the clj.user namespace to call (start) manually.

clj::cljs.user=> (start)
; No available JS runtime.
; See 
clj::cljs.user=> (ns clj.user)
; No available JS runtime.; See 
clj::cljs.user=> (in-ns clj.user)
; No available JS runtime.
; See 


For some reason Calva tries to evaluate (start) in cljs repl. Thus it fails.


I’l have a look @zelark. The reason it runs start is that it is configured as afterCLJReplJackInCode in the connect sequence. To get past that blocker for now you can just remove the afterCLJReplJackInCode entry from the workspace settings.

👌 6

You’ll need to figure out how to start the luminus server, though. And once you figure that out you can probably figure out what that settings should be now, in case you still want it started as part of jack in.


Thanks! I don't mind starting it any which way, I was just trying to follow the various tutorials I found. Appreciate the pointer to afterCLJReplJackInCode.


@pez but why it runs start in cljs repl? It says “`afterCLJReplJackInCode`: Here you can give Calva some Clojure code to evaluate in the CLJ REPL, once it has been created.”


@zelark Why do you think it's trying to run (start) in the CLJS repl? The ouptut says it's connected to the CLJ repl... then the stack trace, then finally it says creating the cljs repl -- after the stack trace.


Oh, I think you're looking at the second bit I pasted? That was just me noodling around. The error is in the snippet above.


Oh, now I see that it is @credulous reporting the problem. 😃


If you look at the status bar, you can see that the current repl is cljs. Also, if you start just a server, it works fine, and start is evaluated.


I just reproduced it locally.


@brandon.ringe could it be something with how we have changed the repl connect code some months ago, you think?


@zelark My status bar says cljc/clj


@zelark since you have it up and running. Can you test if it works to switch to the clj repl and evaluate (start) even when starting both the client and the server?


Oh, sorry then, but mine is cljs


but my prompt shows I'm in the cljs.user namespace. I can't seem to switch to the clj.user namespace, which was the second bit I pasted.


I'm sure this is all operator error - I'm a total newb to this environment. Vim/Fireplace is where i've done my work in the past


I'm assuming this is what we mean by the status bar?


You can switch to the clj repl using the Calva: Toggle REPL Connection used for cljc files


@pez sure, it works, but I need to do (in-ns ’user) first


Iirc, I added a custom command snippet to that project to start the server. If I did, can you try if that one wokrs?


I’ll need to go afk now. Sorry for abandoning you, friends!


@credulous I found a workaround to that. You can just set afterCLJReplJackInCode to "(user/start)" . It works for me.


It lives in <your-project>/.vscode/settings.json


Appreciate the help guys - I had to dash because Parenting


will try this in a couple hours. Thanks!!!


@zelark Thanks for that, sadly didn't work for me:


That error could be because previous failed attempts has leftt something in a bad state. See if it helps closing the project and opening it again.


Yes, actually it ran user/start as the stacktrace says, but then down the road something bad happened

mount.core/start-without (core.cljc:403)
user/start (user.clj:22)


For me it worked using this start code: (in-ns 'user) (start).


Haven’t tried the original one yet, will do that now.


Nope. With that it fails as in @credulous first report. That probably means that something in shadow-cljs has changed since I configured the template, making it start in some other ns. I’ll update the template.


@pez what about this WA, does it work for you?


Since it didn’t work for you, I didn’t try. Will do that in a moment.


It works for me. @ got an error, but I believe it’s something different


Oh, I interpreted this as you ran into troubles later: > but then down the road something bad happened


But you were referring to the logs, I understand now. In any case, I think it is better to change ns first, because that is what has changed.


Tried it with (user/start) now, and that works too for me.

👍 3

Btw, I found another way to fix that, I believe the right one.


As the docs says one can put init-ns in a config file. So I put :init-ns user in project.clj and it fixed the problem.


Is that a top level entry?


No, it’s under :shadow-cljs key

  {:nrepl {:port 7002 :init-ns user}


I'm getting the same error as I got before... this is clearly a problem with my local configuration. I really appreciate you guys digging in! I'm going to try to figure out what's borked on my end.


@credulous make sure that your database is running, probably it’s the cause


I got exactly the same exception when I uncommented :database-url in my dev-config.edn


just found the same thing. It's working now, and I can continue my day knowing I wasted the time of two very helpful people


postgresql wasn't running in the WSL universe


No problem, at least we found a place to fix.


Wow, sorry I'm late to this!


> I found a workaround to that. You can just set `afterCLJReplJackInCode` to `"(user/start)"` . It works for me. Yes, I've found this issue and solution before


I should have documented it somewhere - I don't think I did


Calva friends, if you want to get a taste of some clojure-lsp integration, here's a vsix for the branch that's a WIP: There are indeed rough edges, but I think we can sort them out in time. Feel free to comment on anything unusual/broken on this PR:


With this vsix, go to definition works a bit better (and without a repl connection!), code lens for references exist, and if you click them you can peek the references. You may will see duplicate completions when you have a repl connection. I've yet to get to that, but there's some work to be done there on the lsp side, I think. You may also see some linting of the .calva-repl file, another thing I haven't gotten to, but I think this is a matter of configuration of kondo through lsp.


Also, there's no way to disable code lens for references yet. We'll need to add a setting, as other language clients have done.


Here we go!!!

🚀 15