While troubleshooting and fixing a live reload bug in Clay today, which requires to start a minimal Clojure environment, I figured out how to start a nREPL from the command line. Instead of using M-x cider-jack-in-clj
directly from Emacs, actually we can manully bring up an nREPL with this: clj -Sdeps "{:deps {org.scicloj/clay {:mvn/version \"2-beta21\"} cider/cider-nrepl {:mvn/version \"0.50.2\"}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
(The clay part is only necessary for this debugging), and then connect to this nREPL using the Emacs command M-x cider-connect-clj
.
It's really great, life is much easier with a REPL :)
—
2024-11-09 UPDATE: Another cider nREPL related thing, that is, how to
modify the cider repl parameters when jacking in? Yes, you're right,
use the universal argument of Emacs. There you can, for example,
prepend an extra parameter -A:attach
for clj-async-profiler.
2024-11-12 UPDATE: Here is how to start a nREPL from a deps.clj project root:
clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.3.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.50.2\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[cider.nrepl/cider-middleware\]\"\]\}\}\} -M:dev:cider/nrepl
, after observing how Cider itself jacks in one.