nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
pez 2018-08-05T11:23:49.000039Z

@bozhidar what is the closest to bleeding edge combo of cider-nrepl and nrepl I can use? I tried 0.19-SNAPSHOT with 0.4.4 and that wouldn’t work. Then tried 0.18-SNAPSHOT with 0.4.0 and that seems to work swell.

bozhidar 2018-08-05T11:26:38.000027Z

Both combos work fine for me.

bozhidar 2018-08-05T11:27:00.000014Z

How are you starting the server? What exactly are the problems you’re running into?

pez 2018-08-05T11:31:10.000012Z

It is a small figwheel project that I use when hacking on Calva. I have placed all tooling dependencies in profiles.clj. This works:

{:repl {:plugins [[cider/cider-nrepl "0.18.0-SNAPSHOT"]]
        :dependencies [[nrepl "0.4.0"]
                       [cider/piggieback "0.3.5"]
                       [figwheel-sidecar "0.5.16"]]
        :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}}

bozhidar 2018-08-05T11:31:31.000047Z

It’s piggieback - you need 0.3.8+

bozhidar 2018-08-05T11:31:50.000007Z

And whatever the latest sidecar is.

pez 2018-08-05T11:31:59.000044Z

I’ll try right away.

bozhidar 2018-08-05T11:32:07.000038Z

As for nREPL - 0.4.4

pez 2018-08-05T11:32:33.000008Z

Calva works a lot better with 0.4 than with latest contrib version, btw.

bozhidar 2018-08-05T11:32:33.000071Z

I recall there was something wrong with 0.4.0, so it’s a bad idea to depend on it. The newer, the better.

pez 2018-08-05T11:34:04.000018Z

0.3.8 is newest piggieback?

bozhidar 2018-08-05T11:34:12.000013Z

Yes.

bozhidar 2018-08-05T11:34:24.000014Z

And the first one to support nREPL 0.4. 🙂

pez 2018-08-05T11:35:42.000027Z

Funny that it seemed to work with 0.3.5 and 0.4.0 then.

pez 2018-08-05T11:35:55.000028Z

seem*s*

bozhidar 2018-08-05T11:36:52.000021Z

Can’t imagine how - piggieback 0.3.5 had a hard dep on tools.nrepl, so nREPL 0.4 would not load such middleware 🙂

pez 2018-08-05T11:40:59.000048Z

wow. maybe I still have something in project.clj…

pez 2018-08-05T11:41:19.000026Z

This crashes:

{:repl {:plugins [[cider/cider-nrepl "0.19.0-SNAPSHOT"]]
        :dependencies [[nrepl "0.4.4"]
                       [cider/piggieback "0.3.8"]
                       [figwheel-sidecar "0.5.17-SNAPSHOT"]]
        :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}}

bozhidar 2018-08-05T11:41:44.000033Z

Crashes how?

bozhidar 2018-08-05T11:41:52.000005Z

Ah, now I see.

bozhidar 2018-08-05T11:42:00.000049Z

You’re using lein repl, right?

pez 2018-08-05T11:42:58.000033Z

I do 😃

bozhidar 2018-08-05T11:43:49.000049Z

Lein switched to nREPL only in master, otherwise if you stuck with the contrib one.

bozhidar 2018-08-05T11:44:25.000002Z

The nREPL dep you’ve added is completely ignored and cider-nrepl 0.19 has a hard dep on nREPL 0.4, which I removed in 0.18.

pez 2018-08-05T11:44:31.000056Z

OK. Things work if I change to 0.18-SNAPSHOT

bozhidar 2018-08-05T11:44:47.000008Z

Yep, because you’re back to tools.nrepl then…

pez 2018-08-05T11:44:49.000008Z

I see

bozhidar 2018-08-05T11:45:10.000046Z

@pez See https://github.com/nrepl/lein-nrepl if you want to run 0.4 with lein

pez 2018-08-05T11:45:19.000056Z

So the improvments in Calva behaviour was do to cider-nrepl, I guess

bozhidar 2018-08-05T11:45:39.000039Z

likely so 🙂

pez 2018-08-05T11:46:41.000073Z

For a CLI project 0.19 should work?

pez 2018-08-05T11:48:15.000051Z

I want to write as simple instructions to Calva users as possible. Calva does not yet start the repls and inject stuff so people have to fiddle with these dependencies still.

bozhidar 2018-08-05T11:48:19.000045Z

Yes, but please ignore it completely.

pez 2018-08-05T11:48:32.000015Z

Ignore what?

bozhidar 2018-08-05T11:48:37.000015Z

I created 0.19-snapshot just to experiment with nREPL 0.4.

bozhidar 2018-08-05T11:48:47.000060Z

Eventually I just folded the work in 0.18.

bozhidar 2018-08-05T11:49:22.000031Z

The version number is a bit misleading, but I needed a way to be able to distribute this to people willing to test it.

bozhidar 2018-08-05T11:50:21.000034Z

See the CLI instructions here http://nrepl.readthedocs.io/en/latest/usage/

bozhidar 2018-08-05T11:50:48.000034Z

Basically you can just add cider-nrepl 0.18-SNAPSHOT to the example for piggieback and everything will work just fine.

pez 2018-08-05T12:07:54.000003Z

I am bad at ignoring things 😃 Can confirm that 0.19 didn’t crash things at startup if using the latest lein-nrepl plugin. But some Calva features stopped to work.

pez 2018-08-05T12:13:39.000034Z

I saw that in the lein-nrepl instructions you placed cider-nrepl in :dependencies and not in :plugins.

bozhidar 2018-08-05T12:14:21.000020Z

Yes, that’s intentional.

pez 2018-08-05T12:14:38.000007Z

I am not sure what the difference is. But notice that 0-19 does not work if I keep it in :plugins, but 0.18 does.

bozhidar 2018-08-05T12:15:08.000061Z

The plugin simply overwrites Lein’s repl profile config, but when you’re not using lein repl you don’t want to do this.

bozhidar 2018-08-05T12:16:14.000018Z

Very simply put - the plugin generates something like this section:

:repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}}

bozhidar 2018-08-05T12:16:33.000062Z

(but populated with CIDER’s middlewares)

bozhidar 2018-08-05T12:18:57.000038Z

> But notice that 0-19 does not work if I keep it in :plugins, but 0.18 does.

bozhidar 2018-08-05T12:19:32.000033Z

0.19 doesn’t work because it generates the config, but as Lein is running an incompatible version of nREPL it can’t understand the config.

bozhidar 2018-08-05T12:20:47.000022Z

0.18 on the other hand checks to see if you’re running the old nREPL and uses it API if that’s the case, otherwise it switches to the new one’s API.

bozhidar 2018-08-05T12:21:24.000005Z

This commit should make it clearer

pez 2018-08-05T12:21:25.000040Z

Also, if I move 0.18 to :dependencies the repl starts nicely, but some Calva features stop to work. They work if I keep 0.18 in :plugins.

pez 2018-08-05T12:22:15.000015Z

(Full profile):

{:plugins [[nrepl/lein-nrepl "0.1.1"]]
        :dependencies [[cider/cider-nrepl "0.18.0-SNAPSHOT"]
                       [nrepl "0.4.4"]
                       [cider/piggieback "0.3.8"]
                       [figwheel-sidecar "0.5.17-SNAPSHOT"]]
        :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}

bozhidar 2018-08-05T12:22:19.000019Z

For 0.18 it’s fine to stay as a plugin if you’re using it with tools.nrepl.

bozhidar 2018-08-05T12:23:40.000062Z

And as lein nrepl doesn’t care about the lein repl config it won’t be affected negatively by a cider-nrepl used as a plugin, either.

pez 2018-08-05T12:24:46.000044Z

I’ll do that then, since that’s the config that works. Can I ask for advice about what to instruct Calva users to use? It might be a bit confusing with the above profile, since tools.nrepl will be used anyway, but it seems apt to prepare things for when it is time to move to nrepl.

bozhidar 2018-08-05T12:30:01.000017Z

Generally they can just keep using lein repl like before for a while, so for now you don’t really need to change any instructions. Changes are needed only people using the cli.

bozhidar 2018-08-05T12:32:40.000005Z

For users of the cli - it’s best to suggest the creation of some profile similar to the one described in nREPLs docs. Then it’s important to be careful with the versions of all deps.

bozhidar 2018-08-05T12:33:46.000046Z

I guess I’ll have to list somewhere a note or two about all of this. 🙂