cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
2020-07-19T00:46:30.404300Z

So given a .dir-locals (below) file below i would expect it to find refactor-nrepl because its being passed as a dep (as per the message). my guess is that because were telling shadow to use clojure deps for dependency management it somehow doesn't get passed in.

;; ((nil . (
;;          (cider-preferred-build-tool . shadow-cljs)
;;          (cider-default-cljs-repl . shadow)
;;          (cider-shadow-default-options . "frontend"))))

;; no version of refactor-nrepl

;; WARNING: clj-refactor and refactor-nrepl are out of sync.
;; Their versions are 2.5.0 (package: 20200405.1419) and n/a, respectively.
;; You can mute this warning by changing cljr-suppress-middleware-warnings.[:frontend] Compiling ...

;; message
;; [nREPL] Starting server via /usr/bin/npx shadow-cljs -d nrepl:0.8.0-alpha5 -d cider/piggieback:0.5.0 -d refactor-nrepl:2.5.0 -d cider/cider-nrepl:0.25.3-SNAPSHOT server

2020-07-19T00:47:19.405100Z

my current solution is to avoid using cider jack in and instead to pass all the nrepl deps @ version=release via a clojure deps alias. with the downside that if a version updates then it will be out of sync with my cider version. but i should get a warning.

dpsutton 2020-07-19T01:00:14.408Z

there's nothing in that dir-locals file about refactor-nrepl. where does your expectation come from that "i would expect it to find refactor-nrepl"?

dpsutton 2020-07-19T01:04:05.408700Z

if you cider-jack-in, the following controls what is injected: https://github.com/clojure-emacs/clj-refactor.el/blob/master/clj-refactor.el#L4108

2020-07-19T01:04:18.409400Z

isn't that what -d refactor-nrepl:2.5.0 does? -d is "adds additional dependency'

dpsutton 2020-07-19T01:04:38.409900Z

yes but i think you need to configure the middleware yourself when using deps.edn

2020-07-19T01:05:02.410200Z

so i have to both inject the dep and then tell what to use it?

dpsutton 2020-07-19T01:05:32.410400Z

https://github.com/clojure-emacs/cider/issues/2812

dpsutton 2020-07-19T01:05:56.411100Z

if i'm following correctly yes. you need to get the middleware not just on the classpath but as part of the handlers for nrepl when starting up

dpsutton 2020-07-19T01:08:05.412500Z

If the popular middleware cider-nrepl is found on the classpath (e.g. it’s included in :dependencies), it will be used automatically. No additional configuration required. This can be disabled by setting :nrepl {:cider false}.

dpsutton 2020-07-19T01:08:43.413300Z

so thomas is very nice and looks for cider-nrepl on the classpath and does the right thing. refactor is not privilieged like this and needs to be set up manually

dpsutton 2020-07-19T01:09:21.414Z

one thing you could do is use a bog standard shadow-cljs project and see what cider does and then imitate that (which is what i did in that issue above where they wanted to use deps.edn)

dpsutton 2020-07-19T01:10:11.414200Z

plexus solves this nicely in chui : https://github.com/lambdaisland/chui/blob/master/.dir-locals.el#L10

2020-07-19T01:13:26.415400Z

i'll need to learn some emacs lisp before i can make sense of that. i guesss thats getting higher and higher on my todo list

2020-07-19T01:13:51.416100Z

.it would seem to add nrepl middleware though, which i understand the need for.

dpsutton 2020-07-19T01:14:08.416400Z

this is using cider-jack-in-clojurescript and then adding to the list of cider-jack-in-nrepl-middlewares the value "shadow.cljs.devtools.server.nrepl/middleware"

2020-07-19T01:14:50.417500Z

so in my case i would additional add refactor-nrepl if i wanted it.

dpsutton 2020-07-19T01:14:57.417800Z

which if you use cider-jack-in-clojurescript with shadow and deps you'll need. otherwise you need to add refactor-nrepl into the middleware when starting it up manually from the command line

dpsutton 2020-07-19T01:16:30.419700Z

here's what's going on: 1. from the command line, shadow automatically does its own middleware and cider's 2. from emacs, CIDER will automatically use cider-nrepl and refactor-nrepl middleware. If you want to use deps.edn and shadow from emacs, you need to make sure shadow's middleware is on set up correctly (the dir-locals link i sent you from chui). If you want to start it up from the command line you need to make sure that you get refactor-nrepl middleware manually added in

2020-07-19T01:18:43.420900Z

i see. so i was incorrect, i wont need to add refactor-nrepl if i use said dir-locals.el because what i miss in that setup is the shadow middleware.

dpsutton 2020-07-19T01:19:24.421500Z

that's my understanding yes. refactor-nrepl gets inserted automatically if you are using clj-refactor.el

2020-07-19T01:24:06.424Z

gotcha. This has been very helpful. I think the next thing i need to do is understand what the middleware is doing. But not tonight 🙂

dpsutton 2020-07-19T01:24:52.424800Z

the hardest part about middleware is tracing through the several projects they span and getting a way to prod them in a repl. Sometimes its tough to figure out if you should look in orchard, cider-nrepl, or nrepl itself.

2020-07-19T01:39:19.429600Z

My thought was to have emacs manage the nrepl deps so that I didn't have to sync them. Maybe that's not a good goal. What you explained above makes sense. I think an additional issue was that when I was running shadow cljs from the command line and was passing it nrepl as a dep, I was unable to connect from emacs to the port it exposed.

dpsutton 2020-07-19T03:05:38.432600Z

I think that’s a good goal. And if it’s deps that manages your deps all you need is that middleware bit from chui