Fork me on GitHub
#calva
<
2022-09-01
>
James Pratt10:09:00

Can’t figure out why I can’t get my repl running in calva for this skeleton project: https://github.com/jointprob/jointprob-shadow-cljs

James Pratt10:09:54

I jack in and the build seems to work: npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :my-build-id shadow-cljs - config: /Users/jamespratt/IdeaProjects/jointprob-shadow-cljs/shadow-cljs.edn shadow-cljs - server version: 2.19.9 running at shadow-cljs - nREPL server started on port 49410 shadow-cljs - watching build :my-build-id [:my-build-id] Configuring build. [:my-build-id] Compiling ... [:my-build-id] Build completed. (127 files, 0 compiled, 0 warnings, 1.16s)

James Pratt10:09:56

I get this as REPL output: ; Jacking in... ; Starting Jack-in Terminal: npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :my-build-id ; Hooking up nREPL sessions... ; Connected session: clj ; TIPS: ; - You can edit the contents here. Use it as a REPL if you like. ; - alt+enter` evaluates the current top level form.` ; - ctrl+enter` evaluates the current form.` ; - alt+up` and alt+down traverse up and down the REPL command history` ; when the cursor is after the last contents at the prompt ; - Clojure lines in stack traces are peekable and clickable. clj꞉shadow.user꞉> ; Creating cljs repl session... ; Connecting cljs repl: shadow-cljs... ; The Calva Connection Log might have more connection progress information.

James Pratt10:09:32

I open : http://localhost:9630/index.html Manually in Chrome. The js alert does not appear.

James Pratt10:09:31

I select to connect to :my-build-id

James Pratt10:09:49

get more output in repl window: ; Creating cljs repl session... ; Connecting cljs repl: shadow-cljs... ; The Calva Connection Log might have more connection progress information. ; Connected session: cljs, repl: :my-build-id ; TIPS: You can choose which REPL to use (clj or cljs): ; *Calva: Toggle REPL connection* ; (There is a button in the status bar for this) ; Jack-in done. cljs꞉cljs.user꞉>

James Pratt10:09:33

Enter: (+ 1 1) And get: nil ; No available JS runtime. ; See https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting

James Pratt10:09:07

I’m not properly connecting the client it seems.

James Pratt11:09:43

More info in case it helps. At : http://localhost:9630/dashboard The green light next to my-build-id does not come on unless I press the force compile button.

pez11:09:11

I'm afk. I can only advice to experiment without Calva first. The other day I published a small test project that helps with this a bit, see if the README there makes enough sense to you to help remove Calva from the initial investigation. https://clojureverse.org/t/demystifying-shadow-cljs-nrepl-connect/9277

James Pratt14:09:12

Thanks, it turned out that Calva was working fine. I had missed some settings for shadow-cljs

pez15:09:04

Awesome. The example repo helped you figure that out?

James Pratt15:09:08

yes, thanks for all your work on this extension!

🙏 1
orestis11:09:51

Hello Calva-friends! Coming back from vacation, and Calva doesn't pick up the nRepl port (I start shadow-cljs from an outside terminal). Did something change while I was summering? 😄

pez12:09:21

Could be a regression. I've been touching those parts of Calva a bit. Which project type are you using when connecting?

orestis12:09:46

deps.edn + shadow.cljs

pez12:09:01

And how do you start the REPL?

orestis12:09:21

outside Calva - essentially calling shadow-cljs

pez12:09:47

Then you should use the project type shadow-cljs. See if that works better.

orestis12:09:54

> ls -l .shadow-cljs/
total 48
drwxr-xr-x    3 orestis  staff     96 Jul  5 09:38 babel-worker
drwxr-xr-x    4 orestis  staff    128 Jul  5 09:38 builds
-rw-r--r--    1 orestis  staff      5 Sep  1 13:14 cli-repl.port
-rw-r--r--    1 orestis  staff      4 Sep  1 13:14 http.port
drwxr-xr-x  344 orestis  staff  11008 Sep  1 13:14 jar-manifest
-rw-r--r--    1 orestis  staff      5 Sep  1 13:14 nrepl.port
-rw-r--r--    1 orestis  staff      5 Sep  1 13:14 server.pid
-rw-r--r--    1 orestis  staff     36 Sep  1 13:14 server.token
-rw-r--r--    1 orestis  staff      5 Sep  1 13:14 socket-repl.port

orestis12:09:13

Just for clarifying, the nrepl.port file is there.

orestis12:09:17

Indeed plain shadow-cljs works, I was always using the other as I rely on deps.edn for dependenies. What is the difference between shadow-cljs and deps.edn + shadow-cljs?

pez14:09:49

> Just for clarifying, the nrepl.port file is there. Then it should work. Which version of Calva are you using?

orestis15:09:09

The latest? I will check when back at the screen.

pez15:09:21

> What is the difference between shadow-cljs and deps.edn + shadow-cljs? Very good question. Here's a repository trying to shed some light: https://github.com/PEZ/shadow-w-backend. @danielamber2 and I have recorded a video where we elaborate on it more and I have written a quite lengthy blog article as well, which I will publish when the video has passed post-production. Stay tuned!

🎉 1
orestis06:09:04

Ahh so it's mostly how the REPL is started, not how do you connect to it. Right?

pez09:09:17

That's a good way to put it. The project type is associated with a launch command builder and a connect sequence. The connect sequence has a Clojure part and a ClojureScript part. The Clojure part starts with using the command builder to start the REPL with the needed dependencies, middleware configuration, and app start expression. It can also specify an expression to evaluate once the Clojure REPL is started. When this is done, the ClojureScript part is used to start and connect the ClojureScript REPL. This is all done by evaluating a series of forms on the Clojure REPL. The project types shadow-cljs and deps.ebn + shadow-cljs differ mainly in what command line is used to start the REPL. The reason they get to be extra equivalent in your case there is that you have configured shadow-cljs to in turn start the REPL using clojure. However, which executable is used also determines which tool starts the nREPL server. As for your original error there, shadow-cljs and clojure create their nrepl port files in different places, with different names. Calva looks for a .nrepl-port file in the project root for deps.edn launches, and for a .shadow-cljs/nrepl.port, if it is a shadow-cljs launch. I'm still puzzled why the deps.edn launch didn't work for you. Which version of Calva are you using?

orestis09:09:34

Ah ok, so In my case I actually use shadow-cljs to start the nrepl server (not with the shadow executable, but with the equivalent API call).

orestis09:09:39

So the nrepl port file is where shadow puts it. It is just that it used to work before but got more strict later. No worries, by your description the behavior is correct.

pez09:09:35

Iirc, you can specify the nrepl port file as part of a custom connect sequence. I’m afk and can't confirm.

pez15:09:21

> What is the difference between shadow-cljs and deps.edn + shadow-cljs? Very good question. Here's a repository trying to shed some light: https://github.com/PEZ/shadow-w-backend. @danielamber2 and I have recorded a video where we elaborate on it more and I have written a quite lengthy blog article as well, which I will publish when the video has passed post-production. Stay tuned!

🎉 1