Fork me on GitHub
#nrepl
<
2018-11-22
>
pez08:11:01

@bozhidar, OK. So now I got the time to try this again. If I remove the dependency on sidecar all together, things that used to work, still work (in Calva). Except anything ClojureScript, of course. Is Cider working with ClojureScript using the new nrepl?

bozhidar08:11:15

@pez Of course. 🙂

bozhidar08:11:56

The problem is not nREPL - the problem is the dependency loading got messed up in your case and you’re running one version of the server and middleware that expects the other one.

bozhidar08:11:01

That comes from this code.

bozhidar08:11:17

I hope that this makes sense. With user.clj your altering the expected load order of the libraries, so and in your case it seems to me that sidecar loads the legacy tools.nrepl at some point even though you’re actually trying to connect to the new one.

bozhidar08:11:14

That’s going to be fixed for good when I completely kill the support for tools.nrepl in a release or two. But for now without a lein release in a long time it was necessary.

pez08:11:40

I think I have understood that the problem is not nREPL. 😄 But even without user.clj I get that trace as long as I have a dependency on sidecar. And without sidecar I don’t know how to start the cljs repl (for Figwheel projects).

dominicm08:11:27

It's to do with lazy Loading @bozhidar

dominicm08:11:46

Because we lazily load middleware, it finds a different nrepl at different points

bozhidar08:11:37

@dominicm Yeah, but this can only happen if some dep explicitly requires tools.nrepl in the mean time, which should not happen most of the time.

dominicm08:11:46

Why shouldn't it?

bozhidar08:11:43

Because I assume that most libraries will follow the same pattern as us - have a hard dep on nrepl and dynamically select tools.nrepl if it happens to be present. At least that’s what all the libs I’m involved with do.

pez08:11:20

So, I should file a PR on sidecar doing that?

pez08:11:11

I’m still puzzled how you get the cljs repl up without sidecar, @bozhidar

bozhidar08:11:48

@pez It’s all about the load order - if you load all middleware first this is going to work just fine.

pez08:11:26

Right, so no PR needed. 😃

bozhidar08:11:29

When I tested this it worked just fine for me.

pez08:11:19

I don’t know how to configure the load order, I guess.

bozhidar08:11:21

Probably just changing the dependency that sidecar has is going to fix this, but I don’t have time to look into this. You can update project.clj, build it locally and try.

bozhidar08:11:52

If no other lib you use has a dep on tools.nrepl then this must the root cause of the problem.

pez08:11:54

OK, I’ll do that right away.

pez08:11:09

But it still seems strange that I need a patched sidecar, when you don’t. There is something important I am not getting here.

bozhidar09:11:06

I’m not using user.clj.

pez09:11:14

Me neither.

bozhidar09:11:30

I just start figwheel via cider-jack-in and that’s it.

bozhidar09:11:53

But I also have no other deps. I always do just very basic cljs tests as I don’t do cljs myself.

pez09:11:34

OK. So I should look at what cider-jack-in does. It was a while since I did that. Calva needs something similar. Badly.

bozhidar09:11:27

I assume it’s going to be pretty easy for you to just carbon-copy CIDER’s approach, as there’s nothing specific about it.

bozhidar09:11:16

We just build a command string that will start nREPL + the necessary middleware, run it and parse its output to check when the server has started.

bozhidar09:11:47

Then we open a connection the server - business as usual.

pez09:11:37

Yes, I think the trickiest part will be how to know when I can connect.

pez09:11:49

OK. So if I remove that dependency from sidecar’s projectclj and move piggieback up before nrepl in :dependencies, then it works. I can even have my user.clj and use that for starting the cljs repl.

bozhidar09:11:56

We’re making progress. 🙂

cider 4
calva 4
pez10:11:54

For some misconfigurations, sidecar (I think) gives some hints about piggieback and adds:

Note: Cider will inject this config into your project.clj.
This can cause confusion when your are not using Cider.
You could say that again. 😄

bozhidar10:11:10

@pez But now you’re enlightened! That’s always a good thing!

pez10:11:24

I am trying to cling on to this new knowledge. As well as act on the, not so subtle, hints the process has given me about the need for calva-jack-in.

pez10:11:18

Also questioning my decision to start with tooling for a language that was so new to me, in all ways possible. But I’ll compensate with a blood, sweat, tears and a happy mood…

bozhidar10:11:14

Well, the process was relatively similar for me as well. I started CIDER with relatively little experience with Clojure, but it somehow worked out (more or less) well.

bozhidar10:11:37

Passion and hard work can get you anywhere. 🙂

bozhidar10:11:04

(and hard liquor 😉 )

pez10:11:19

I should now confess that most often I go for Bourbon over Calva.

bozhidar13:11:42

Don’t speak to me about bourbon now - I had a fun encounter with two bottles of it a day ago and I’m still recovering. 😄

pez14:11:08

Just you and two bottles?