I'm trying to run a repl with deps dependencies in spacemacs (CIDER session). This is my deps.edn:
{:paths ["src"]
:deps {org.clojure/tools.namespace {:mvn/version "1.5.0"}
org.clojure/clojure {:mvn/version "1.12.0"}
org.clojure/core.async {:mvn/version "1.6.681"}}
:aliases
{:test {:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}}}
:run-test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
:main-opts ["-m" "kaocha.runner"]}}}
Now, in order to also add the test.check dependencies to the repl, I added .dir-locals.el:
((clojure-mode . ((cider-clojure-cli-global-options . "-M:test"))))
However, I must have misconfigured something, since when I try to run cider-jack-in:
Starting new CIDER session ...
[nREPL] Starting server via /usr/local/bin/clojure -M:test -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:cider/nrepl
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-Sdeps (No such file or directory)
So basically, how to make sure cider also loads the test dependencies (so I can run/test the tests in the repl)?You should use cider-clojure-cli-aliases instead of cider-clojure-cli-global-options (the later is for using in init.el to set it globally for all project), and you also shouldn't add -M prefix:
(cider-clojure-cli-aliases . ":test")also, from M-x describe-variable:
cider-clojure-cli-global-options is a variable defined in 'cider.el'.
Its value is nil
This variable is obsolete since 1.8.0; use
'cider-clojure-cli-parameters' instead.The "-Djdk.attach.allowAttachSelf" doesn't help in my case of a loop. It's still running. The positive side is that the repl is able to respond to new request. Seems like a jvm 20+ side of limitation but this seems fixed.
https://github.com/nrepl/nrepl/issues/296
https://github.com/clojure-emacs/cider/issues/3351#issuecomment-1587036038
> nREPL server started on port 41951 on host localhost - <nrepl://localhost:41951>
> ERROR:
> java.lang.UnsupportedOperationException
> at java.base/java.lang.Thread.stop(Thread.java:1659)
> at nrepl.middleware.session$interrupt_stop$fn__1457.invoke(session.clj:198)
> at clojure.core$binding_conveyor_fn$fn__5842.invoke(core.clj:2047)
> at clojure.lang.AFn.call(AFn.java:18)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
> at java.base/java.lang.Thread.run(Thread.java:1575)
What does (System/getProperty "jdk.attach.allowAttachSelf") return in the REPL?
Also, please check what nrepl version do you run. You can see that via cider-classpath.
I think you get an old nrepl 1.1.1 pulled as a dependency of cider-nrepl. Try adding an explicit nrepl/nrepl {:mvn/version "1.3.0"} dependency to the alias.
Side question to @bozhidar: I see we rarely bump the nrepl dependency in cider-nrepl. I assumed that nrepl has to be provided explicitly (like cider-jack-in does), so I didn't bother bumping the version there. What is your take, should the user be able to include just cider-nrepl and rely on it pulling nrepl as a dependency? If not, maybe we should drop nrepl dependency from cider-nrepl completely.
I think it's best to bump it, as not everyone is using cider-nrepl with CIDER.
I just keep forgetting about this, as most of us working on cider-nrepl use CIDER. 😄
We can mark the dependency as :provided, but I'm not sure if that keyword matters at all, tbh.
What operating system do you run?
arch linux x64
> $ java -version > openjdk version "23" 2024-09-17 > OpenJDK Runtime Environment (build 23) > OpenJDK 64-Bit Server VM (build 23, mixed mode, sharing) > > $clj -Stree -M:cider-clj1 > org.clojure/clojure 1.12.0 > . org.clojure/spec.alpha 0.5.238 > . org.clojure/core.specs.alpha 0.4.74 > nrepl/nrepl 1.3.0 > cider/cider-nrepl 0.50.3 > X nrepl/nrepl 1.1.1 :use-top > . cider/orchard 0.28.0 > . mx.cider/logjam 0.3.0
Hm, should be working then. Do you see any errors/warnings in *nrepl-server ....* buffer that corresponds to your REPL?
no. it's clean
Even after you run the loop and interrupt it, right?
oh you are right it's working now.
nrepl/nrepl is it i guess.
tyvm!
You are welcome, glad it worked
user> (System/getProperty "jdk.attach.allowAttachSelf") "" user> (System/getProperty "jdk.attach.allowAttachSelff") nil i didn't realize empty string is the expected result. now i know.
Yeah, it's weird but that how it works