Fork me on GitHub

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 🙌


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

🙌 1
👍 1

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!! 🙌

❤️ 1

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.


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


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


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.

✔️ 1

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


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


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?