Fork me on GitHub
#calva
<
2020-12-05
>
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.

credulous14:12:15

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:

credulous14:12:12

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)
nil
; No available JS runtime.
; See 
clj::cljs.user=> (ns clj.user)
nil
; No available JS runtime.; See 
clj::cljs.user=> (in-ns clj.user)
nil
; No available JS runtime.
; See 
clj::cljs.user=> 

alekszelark14:12:22

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

pez14:12:45

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.

👌 2
pez14:12:14

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.

credulous14:12:51

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.

alekszelark14:12:45

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

credulous14:12:20

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

credulous14:12:00

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.

pez14:12:39

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

alekszelark14:12:11

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.

alekszelark14:12:17

I just reproduced it locally.

pez14:12:46

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

credulous14:12:23

@zelark My status bar says cljc/clj

pez14:12:45

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

alekszelark14:12:48

Oh, sorry then, but mine is cljs

credulous14:12:04

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.

credulous14:12:30

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

credulous14:12:17

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

pez14:12:58

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

alekszelark14:12:13

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

pez15:12:15

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

pez15:12:42

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

alekszelark15:12:48

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

alekszelark15:12:37

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

credulous15:12:32

Appreciate the help guys - I had to dash because Parenting

credulous15:12:56

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

credulous16:12:53

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

pez16:12:51

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.

alekszelark16:12:03

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)

pez16:12:01

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

pez16:12:39

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

pez16:12:52

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.

alekszelark16:12:25

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

pez16:12:09

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

alekszelark16:12:40

It works for me. @https://app.slack.com/team/U0LJ1RNS0 got an error, but I believe it’s something different

pez16:12:35

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

pez16:12:41

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.

pez16:12:01

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

👍 1
alekszelark16:12:50

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

alekszelark16:12:37

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.

credulous16:12:43

Is that a top level entry?

alekszelark16:12:13

No, it’s under :shadow-cljs key

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

credulous17:12:08

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.

alekszelark17:12:18

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

alekszelark17:12:34

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

credulous17:12:16

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

credulous17:12:56

postgresql wasn't running in the WSL universe

alekszelark17:12:23

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

bringe17:12:59

Wow, sorry I'm late to this!

bringe17:12:08

> 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

bringe17:12:19

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

bringe21:12:48

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: https://8915-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.135-feat-lsp-client-853d7c2e.vsix 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: https://github.com/BetterThanTomorrow/calva/pull/572

bringe21:12:51

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.

bringe21:12:07

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.

pez21:12:28

Here we go!!!

🚀 5