Ok, the solutions I think I found.... 1) I still don't know, but I saw when cider launches a repl it uses nrepl-cmdline which seems to be saving the port a file on the root of the project (.nrepl-port) https://github.com/nrepl/nrepl/blob/be37e0ebd13c2d341bf6a7bcd5735da45b78f909/src/clojure/nrepl/cmdline.clj#L403-L413
2) I thin figwheel launches a single nREPL server, the cmds to cljs or clj are "redirected" through the use of the piggieback middleware, so I shouldn't try to run two nREPLS
3) is basically answered by 2).. 🙂
founds this project that solved the cider-jack-in-clj&cljs
debacle for me: https://github.com/EmmanuelOga/deps-cider-cljs-reagent
the "secret sauce" seems to be the config on .dir-locals.el, which customize the way cider launches the repl: https://github.com/EmmanuelOga/deps-cider-cljs-reagent/blob/master/.dir-locals.el
it instructs cider to use the -A:cider
alias cmd, and in deps.edn there's a corresponding alias that enables figwheel. There's also config to automatically select a repl of figwheel-main
type and the dev
build.
sigh, that was a lot to write. Hopefully it will help someone, maybe not 🙂
You should put this on a blog (or just a Gist)! It's useful information.
ah, good point, will do 🙂
> how do you do that with figwheel? Just like you'd do in a regular, non-figwheel project. Figwheel doesn't come with nrepl baked-in:
$ clj -Acider -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.6.0"}}}' -m nrepl.cmdline
...
nREPL server started on port 49712 on host localhost - <nrepl://localhost:49712>
...
[Figwheel] Starting Server at <http://localhost:9500>
[Figwheel] Starting REPL
Then we can connect to the nrepl with a client. (cider is a client, but so is this other command line tool)
$ clojure -Sdeps '{:deps {reply {:mvn/version "0.4.3"}}}' -m reply.main --attach localhost:49712
REPL-y 0.4.3, nREPL 0.6.0
...
user=> (require '[figwheel.main.api :as fig])
nil
user=> (fig/start "dev")
Prompt will show when REPL connects to evaluation environment (i.e. a REPL hosting webpage)
Figwheel Main Controls:
(figwheel.main/stop-builds id ...) ;; stops Figwheel autobuilder for ids
...
user=>
(i.e. where we were with `-A:figwheel` or `clojure -m figwheel.main -b dev -r`, but using nrepl)
Note that it'll also complain of other missing pieces (e.g. piggieback middleware for CLJS support). Either you add them to the project, to your user profile, or use the jack-in-*
commands (which add those for you)thx! took me a while but I figured out cider jack in was running the repl cmd line
clojure -A:cider -Sdeps '{:deps {nrepl {:mvn/version ""0.6.0""} cider/piggieback {:mvn/version ""0.4.2""} cider/cider-nrepl {:mvn/version ""0.23.0""}}}' -m nrepl.cmdline --middleware '[""cider.nrepl/cider-middleware"", ""cider.piggieback/wrap-cljs-repl""]'