Fork me on GitHub
#cider
<
2021-03-28
>
oxalorg (Mitesh)19:03:12

cide-jack-in-clj is not injecting the middlewares properly and I'm unable to figure out how to debug this. It's either blank or incomplete, but this happens only "sometimes". Here's a screenshot where I open two emacs, go to same project, and try to jack in. On the first try jack-in created this unexpected command (notice the missing middleware list)

;;  Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.3"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.5"}}}' -m nrepl.cmdline --middleware '[]'
On the second try jack-in created this expected command
;;  Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.3"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.5"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor","cider.nrepl/cider-middleware"]'
Everything else is exactly the same. The project consists of a blank clojure file with ns, with a blank deps.edn. But I face this issue about once a day. Any hints on how should I try to debug this? Could this be an issue due to clojure-lsp? Any help would be super appreciated 🙌

ericdallo21:03:13

I can guarantee that clojure-lsp has nothing related with a REPL issue 🙂 clojure-lsp is static analysis, nothing related with REPL

🙌 3
👍 3
oxalorg (Mitesh)21:03:51

Thank you! I was a bit suspicious because clojure-lsp was the most recent change I had made to my config. BTW love using clojure-lsp thanks for all your work!! 🙌

❤️ 3
blak3mill3r20:03:18

That's mysterious. I wonder if there's something in your user ~/.clojure/deps.edn that is causing this. I suggest commenting out everything there and see if cider-jack-in-clj works.

blak3mill3r20:03:12

also there is a file called ~/.nrepl/nrepl.edn that can configure the nrepl middleware, if it is there

blak3mill3r20:03:51

and possibly take precedence over cider's ... maybe ... I would hope that the --middleware CLI option would take precedence there but check if you have that nrepl.edn file

dpsutton20:03:23

its none of that. the startup command is emitted from vars in emacs. what ultimately is resolved at runtime might include those config files that but that literal string is constructed looking solely at emacs vars. The function doing all of this is cider-clojure-cli-jack-in-dependencies and you can see that the middleware is from (cider-jack-in-normalized-nrepl-middlewares). Evaluating just this should help you check this faster than waiting on all of the jvm startup. Everything is sourced from a variable called cider-jack-in-nrepl-middlewares. If that is set you should be good to go, otherwise it will be empty.

✔️ 3
dpsutton20:03:08

I would look in your init or any dir locals files that might set this variable

oxalorg (Mitesh)21:03:16

Yes I don't think those files are the problem here. I've tried to inspect the cider-jack-in-nrepl-middlewares variable and that is empty whenever this jack-in command misbehaves. But the problem is figuring out why is it empty only sometimes? :thinking_face: This happens even when there are no .dir-locals.el file so that can't be the problem

oxalorg (Mitesh)21:03:31

Also like I said if this were a configuration problem it should have been reproducible consistently, i.e. the middlewares should always have been empty. What I'm thinking is that maybe switching between multiple-projects somehow messes up the cider-jack-in-nrepl-middlewares state?

dpsutton21:03:34

It never has for me. This smells like local shenanigans

3
✔️ 3
oxalorg (Mitesh)22:03:51

Thanks for the help! I'll try to somehow reproduce the issue properly. 🙂

oxalorg (Mitesh)22:03:36

It most definitely does look like an issue from my end rather than from CIDERs end!