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
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.
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"?
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
isn't that what -d refactor-nrepl:2.5.0
does? -d is "adds additional dependency'
yes but i think you need to configure the middleware yourself when using deps.edn
so i have to both inject the dep and then tell what to use it?
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
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}.
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
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)
plexus solves this nicely in chui : https://github.com/lambdaisland/chui/blob/master/.dir-locals.el#L10
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
.it would seem to add nrepl middleware though, which i understand the need for.
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"
so in my case i would additional add refactor-nrepl if i wanted it.
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
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
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.
that's my understanding yes. refactor-nrepl gets inserted automatically if you are using clj-refactor.el
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 🙂
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.
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.
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