nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
pez 2018-11-22T08:01:01.192900Z

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

bozhidar 2018-11-22T08:34:15.193100Z

@pez Of course. 🙂

bozhidar 2018-11-22T08:34:56.194Z

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.

bozhidar 2018-11-22T08:35:01.194200Z

That comes from this code.

bozhidar 2018-11-22T08:37:17.195800Z

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.

bozhidar 2018-11-22T08:38:14.197300Z

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.

pez 2018-11-22T08:42:40.199700Z

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

dominicm 2018-11-22T08:44:27.200100Z

It's to do with lazy Loading @bozhidar

dominicm 2018-11-22T08:44:46.200800Z

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

bozhidar 2018-11-22T08:45:37.201600Z

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

dominicm 2018-11-22T08:45:46.201800Z

Why shouldn't it?

bozhidar 2018-11-22T08:46:43.202900Z

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.

pez 2018-11-22T08:48:20.203800Z

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

pez 2018-11-22T08:49:11.204400Z

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

bozhidar 2018-11-22T08:49:48.205Z

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

pez 2018-11-22T08:52:26.206300Z

Right, so no PR needed. 😃

bozhidar 2018-11-22T08:52:29.206400Z

When I tested this it worked just fine for me.

pez 2018-11-22T08:53:19.207600Z

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

bozhidar 2018-11-22T08:53:21.207800Z

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.

bozhidar 2018-11-22T08:53:52.208700Z

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

pez 2018-11-22T08:53:54.208800Z

OK, I’ll do that right away.

pez 2018-11-22T08:55:09.209700Z

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

bozhidar 2018-11-22T09:00:06.210Z

I’m not using user.clj.

pez 2018-11-22T09:00:14.210400Z

Me neither.

bozhidar 2018-11-22T09:00:30.210800Z

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

bozhidar 2018-11-22T09:00:53.211300Z

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

pez 2018-11-22T09:02:34.212300Z

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

bozhidar 2018-11-22T09:17:27.214Z

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.

bozhidar 2018-11-22T09:18:16.214900Z

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.

bozhidar 2018-11-22T09:18:47.215300Z

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

pez 2018-11-22T09:27:37.217500Z

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

pez 2018-11-22T09:30:49.218400Z

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.

bozhidar 2018-11-22T09:54:56.218700Z

We’re making progress. 🙂

11
pez 2018-11-22T10:16:54.220500Z

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

bozhidar 2018-11-22T10:29:10.220900Z

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

pez 2018-11-22T10:31:24.222500Z

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.

pez 2018-11-22T10:34:18.224700Z

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…

bozhidar 2018-11-22T10:36:14.225600Z

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.

bozhidar 2018-11-22T10:36:37.226100Z

Passion and hard work can get you anywhere. 🙂

bozhidar 2018-11-22T10:38:04.226300Z

(and hard liquor 😉 )

pez 2018-11-22T10:52:19.227700Z

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

bozhidar 2018-11-22T13:45:42.228300Z

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

pez 2018-11-22T14:00:08.228600Z

Just you and two bottles?