Fork me on GitHub
#calva
<
2022-01-11
>
orestis15:01:43

I'm trying out for the first time Calva jack-in. What's the difference between a deps.edn + shadow-cljs vs just shadow-cljs? In my case the first one doesn't work (I get an error about unable to connect to the CLJS repl) whereas the second version works just fine.

orestis15:01:13

But when I was starting the REPL outside of Calva, connecting via deps.clj + shadow-cljs was the working one.

pez15:01:22

The difference is that the former will start the REPL using clojure rather than with npx shadow-cljs. I think it fails because we’re missing to inject the shadow devtools as a dependency.

orestis15:01:26

Yeah it seems that when I start with the former, shadow-cljs builds are not started...

orestis15:01:08

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"0.9.0"},cider/cider-nrepl {:mvn/version,"0.27.4"}}}' -M:dev:cljs:i18n:test -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" this the jack-in command copied to the clipboard.

pez15:01:29

To get it to work with jack-in right now, you’ll need to have the shadow dependencies set up in some deps.edn alias. If I am correct that this is what is amiss.

pez15:01:54

Is there a reason you don’t use shadow-cljs jack-in or are you just curious? 😃

orestis15:01:22

shadow-cljs is part of the cljs deps so I think that's not the case

orestis15:01:44

I'm curious because I wanted to see how calva starts shadow-cljs builds from within a deps.edn file 🙂

orestis15:01:55

But I can share with the team the shadow-cljs jack-in command 🙂

pez15:01:25

Indeed, you said you had it working if you started it manually and connected… I don’t remember if we track this on github, but if we don’t, we should. My goldfish memory is far from enough.

orestis15:01:04

I will continue exploring this, there seems to be a race condition somewhere in our code because both shadow and our system will load the same files. My goal would be to start via clojure and then execute some code to start the desired shadow builds (but only after our project starts)

orestis15:01:33

Dinner time! Thanks for all the efforts on Calva!

orestis19:01:34

So if you start nrepl outside of it (via a plain -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" command, that middleware isn't applied.

orestis19:01:14

So given the complexity of that, the solution is to let shadow-cljs start nrepl for you (as it does by default) and not start nrepl via the nrepl.cmdline.

orestis19:01:23

shadow-cljs will load the cider.nrepl/cider-middleware if it's on the classpath though.

orestis19:01:39

I will package all of this into an issue with a problem statement, sorry for the noise 🙂

pez20:01:51

Oh, please continue to make noise! Issue also welcome.

orestis05:01:05

I think it's relevant to this https://github.com/BetterThanTomorrow/calva/issues/1307 I will keep digging.

orestis15:01:44

In the context of a Jack-in command, can I make Calva prompt me for extra deps to pass in? For example, I may want to sometimes use extra deps that come from my user deps.edn, but not always.

pez15:01:52

Jack-in should prompt you for aliases always. However, it does not read your user aliases, so you will need to configure those using a setting something.myAliases (i’ve forgotten the prefix right now…)

orestis15:01:45

Nice, that makes them show up on the menu, but in the context of a custom sequence (which is checked in to git to share with the team) I don't want to bake those in. So I'd like to e.g. press "shift-enter" on that UI and get the menu selection so I can check in an extra dependency...

orestis15:01:38

Not a big deal, I'm the only user of Calva anyway so I can push those settings out to my user instead of the workspace, or I can add an extra custom sequence with a dependency to portal...

pez15:01:44

We should probably read the user deps.edn…

pez15:01:26

VS Code does not allow for the shift+enter solution, but for the record: I like it. 😃

orestis15:01:55

(BTW, the custom sequences and the docs on them are pretty good, I managed to remove cider-nrepl from our deps.edn entirely so that Calva injects that, and run custom code to start our http server! Woo!)

🎉 1
pez15:01:24

This stuff was initially developed “documentation first”, that is I first wrote the docs and tweaked the docs and such, then started to implement. I haven’t kept up the discipline when tweaking the feature, but really I should.