Fork me on GitHub
#cider
<
2020-07-19
>
Drew Verlee00:07:30

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

Drew Verlee00:07:19

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.

dpsutton01:07:14

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

Drew Verlee01:07:18

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

dpsutton01:07:38

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

Drew Verlee01:07:02

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

dpsutton01:07:56

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

dpsutton01:07:05

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

dpsutton01:07:43

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

dpsutton01:07:21

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)

Drew Verlee01:07:26

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

Drew Verlee01:07:51

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

dpsutton01:07:08

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"

Drew Verlee01:07:50

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

dpsutton01:07:57

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

dpsutton01:07:30

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

Drew Verlee01:07:43

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.

dpsutton01:07:24

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

Drew Verlee01:07:06

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 🙂

dpsutton01:07:52

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.

Drew Verlee01:07:19

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.

dpsutton03:07:38

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