cider

2024-12-16T12:58:36.779589Z

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)?

Roma 2024-12-16T13:02:22.699839Z

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")

💯 1
a13 2024-12-16T13:04:31.733559Z

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.

👌 1
2024-12-16T13:07:44.759289Z

@rrudakov thx, seems to work fine! @a13 right, should've checked that (although it wouldn't have pointed me to the aliases directly 🙂 )

Apple 2024-12-16T13:48:42.590439Z

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)

oyakushev 2024-12-16T14:55:40.495099Z

What does (System/getProperty "jdk.attach.allowAttachSelf") return in the REPL?

oyakushev 2024-12-16T14:56:50.976969Z

Also, please check what nrepl version do you run. You can see that via cider-classpath.

oyakushev 2024-12-16T15:26:33.142579Z

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.

oyakushev 2024-12-16T15:28:22.187879Z

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.

bozhidar 2024-12-16T15:29:25.531829Z

I think it's best to bump it, as not everyone is using cider-nrepl with CIDER.

bozhidar 2024-12-16T15:29:54.519149Z

I just keep forgetting about this, as most of us working on cider-nrepl use CIDER. 😄

oyakushev 2024-12-16T15:37:42.682259Z

We can mark the dependency as :provided, but I'm not sure if that keyword matters at all, tbh.

Apple 2024-12-16T18:04:24.464309Z

oyakushev 2024-12-16T18:05:04.133669Z

What operating system do you run?

Apple 2024-12-16T18:05:20.051509Z

arch linux x64

Apple 2024-12-16T18:06:03.672869Z

> $ 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

oyakushev 2024-12-16T18:06:27.525919Z

Hm, should be working then. Do you see any errors/warnings in *nrepl-server ....* buffer that corresponds to your REPL?

Apple 2024-12-16T18:06:49.651149Z

no. it's clean

oyakushev 2024-12-16T18:07:13.632209Z

Even after you run the loop and interrupt it, right?

Apple 2024-12-16T18:08:53.174199Z

oh you are right it's working now.

😁 1
Apple 2024-12-16T18:09:17.892719Z

nrepl/nrepl is it i guess.

Apple 2024-12-16T18:09:37.059999Z

tyvm!

oyakushev 2024-12-16T18:09:45.184139Z

You are welcome, glad it worked

Apple 2024-12-16T18:10:11.366549Z

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.

👍 1
oyakushev 2024-12-16T18:10:34.838239Z

Yeah, it's weird but that how it works