@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?
@pez Of course. 🙂
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.
That comes from this code.
https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl.clj#L8
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.
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.
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).
It's to do with lazy Loading @bozhidar
Because we lazily load middleware, it finds a different nrepl at different points
@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.
Why shouldn't it?
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.
So, I should file a PR on sidecar doing that?
I’m still puzzled how you get the cljs repl up without sidecar, @bozhidar
@pez It’s all about the load order - if you load all middleware first this is going to work just fine.
As you can see sidecar has support for the new nREPL https://github.com/bhauman/lein-figwheel/blob/dfd010d372280746f64397328fb9a402d448276d/sidecar/src/figwheel_sidecar/components/nrepl_server.clj#L6
Right, so no PR needed. 😃
When I tested this it worked just fine for me.
I don’t know how to configure the load order, I guess.
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.
If no other lib you use has a dep on tools.nrepl then this must the root cause of the problem.
OK, I’ll do that right away.
But it still seems strange that I need a patched sidecar, when you don’t. There is something important I am not getting here.
I’m not using user.clj
.
Me neither.
I just start figwheel via cider-jack-in and that’s it.
But I also have no other deps. I always do just very basic cljs tests as I don’t do cljs myself.
OK. So I should look at what cider-jack-in does. It was a while since I did that. Calva needs something similar. Badly.
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.
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.
Then we open a connection the server - business as usual.
Yes, I think the trickiest part will be how to know when I can connect.
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.
We’re making progress. 🙂
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. 😄@pez But now you’re enlightened! That’s always a good thing!
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.
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…
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.
Passion and hard work can get you anywhere. 🙂
(and hard liquor 😉 )
I should now confess that most often I go for Bourbon over Calva.
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. 😄
Just you and two bottles?