Hello team, I'm having a new issue as of this morning's updates. The cider-jack-in command somehow creates a repl environment without the correct classpath. I still get the correct Startup: command in the repl buffer. The repl created from cider-jack-in starts very quickly, whereas the classpath I expect is heavy and it takes a few seconds to open normally. If I copy the Startup command verbatim to a terminal, it works, and I can cider-connect and it creates the classpath correctly.
(`clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.7.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.59.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[cider.nrepl/cider-middleware\]\"\]\}\}\} -M:test:repl:notebooks:cider/nrepl`)
To compare, I ran this command in both repls to count the classpath entries: (count (str/split (System/getProperty "java.class.path") (re-pattern (System/getProperty "path.separator"))))
For the cider-created repl buffer, this value is 12
If I run the exact same startup in the terminal and count the classpath entries, I get the correct 336.
I've got a work-around for now, but thought reporting it here could help somehow.
Is the repl started in the correct folder ? The change to use project.el messed up my setup too because my setup is a bit weird with regards to projectile
you are spot on, this is exactly the issue.
ugh - my clojure project is in a sub-folder of the project, because it's kindof polyglot project
I still think there is an issue, deps.edn detection should have precedence over .git detection given it's in the cider-build-tool-files list, but for some reason it's not working
Are you aware of a way to customize or override this in something like .dir-locals.el? I might have missed it, but didn't find anything after a quick scan of the docs
I use projectile so right now I've just created an empty .projectile file at the root of each of my clojure projects until I find the root cause
without it, maybe a .project file instead ?
I use projectile too; I'll try it
had to restart emacs to get rid of the hidden state, but it does work for me. Thank you
I had the same problem (Clojure and deps.edn in a subfolder of a project, cider not seeing it), which started recently and, after banging my head for more than an hour, this was the solution that seems to work:
;; To see `deps.edn` inside of a subdirectory
(with-eval-after-load 'projectile
(add-to-list 'projectile-project-root-files-bottom-up "deps.edn"))(setq projectile-project-root-files-bottom-up (append projectile-project-root-files-bottom-up cider-build-tool-files)) to get them all. Still confused as to why projectile would impact project.el, I thought they were independent. Could it be doom-emacs messing with this ?
Whatever is causing this, it wasn't there until recently. The same project I have problems with right now, worked flawlessly for past 6 months.
yes it's this change: https://github.com/clojure-emacs/cider/commit/f81bb0dba48d762c5a64681a449cfe0cf7f746d3
The solution I used (empty clj/.projectile ) is a little awkward in practice. My projectile-find-file now hides all the files not in clj/**.
I confirmed that I get the same behaviour from modifying projectile-project-root-files-bottom-up in the way above.
Is this a problem for others or just me?
cc @bozhidar
I’ll take look when I can. Seems I’ve messed something up while trying to simplify the jack-in logic recently. Sorry about that!
I’ve pushed a fix that should solve the issue. I most the project root resolution from clojure-mode to cider to avoid having to depend on clojure-mode for it, but in my attempt to make the code “smarter” I made a very silly mistake. I’ll think more about the overall approach here, but things should work for now.
thanks that solved the issue for me
Glad to hear this!
Solved the problem for me too. Thanks @bozhidar for a quick fix!!
I just updated and tested, it works like before, thank you for the fix @bozhidar 🙏🏽
I had a live coding exercise today with cider that didn’t go well. I had a bug in my code which was an infinite loop. When I pressed C-M-x it never returned. How can I interrupt this and continue? I ended up killing the buffer several times and restarting slime.
cider-interrupt
and https://docs.cider.mx/cider/usage/code_evaluation.html#enable-evaluation-interrupts-on-java-21-and-newer if you start the nrepl from cider
> cider-interrupt do you mean M-x cider-interupt ?
@rolthiolliere sorry, i took a look at the links you suggested. I think i’m missing too much background information about how cider works to relate these paragraphs to action I should take to ameliorate my problem. I don’t understand how cider and nrepl work, I’m just a user. What should I do if I want to interrupt an infinite loop launched by C-M-x ?
yes M-x cider-interrupt, (or C-c C-c). If you use java 21 you need to add the nrepl agent when launching it. The doc I sent was only to automatically add the correct argument to the nrepl launch command, in case you start the nrepl with cider-jack-in
So basically, if you use java 21 or above:
• if you start nrepl from your terminal and then connect to it with cider-connect: follow nrepl doc
• if you use cider-jack-in: follow the cider doc (https://docs.cider.mx/cider/basics/up_and_running.html#enabling-nrepl-jvmti-agent)
I have :aliases {:dev {:jvm-opts ["-Djdk.attach.allowAttachSelf"]} in my deps.edn
and ((clojure-mode . ((cider-clojure-cli-aliases . ":dev")))) in .dir-locals.el
if i’m using cider-jack-in do I need to do what the IMPORTANT section says, or only if I’m using cider-connect ?
otherwise how am I supposed to do the following:
> To enable the agent, the Java process should be launched with -Djdk.attach.allowAttachSelf.
I don’t understand how to launch the java process with that flag
to me the documentation is contradictor or at least confusing
if you're using cider-jack-in you can add this to .dir-locals.el for projects that use java 21:
((cider-mode . ((cider-enable-nrepl-jvmti-agent . t))))
ahh I need to do this in every project that uses java 21 and higher?
or in your emacs config:
(use-package 'cider
:config (setq cider-enable-nrepl-jvmti-agent t))> ahh I need to do this in every project that uses java 21 and higher? maybe it has no effect for older versions, maybe it crashes, not sure. I use java 21 everywhere so I enabled that globally
Here is the relevant section in my .emacs file.
(custom-set-variables
'(ispell-program-name "/usr/local/bin/ispell")
'(package-selected-packages
'(cider clojure-mode csv-mode exec-path-from-shell flycheck
flycheck-clj-kondo hl-sexp lsp-metals lsp-mode lsp-ui magit
markdown-mode paredit sbt-mode scala-mode use-package w3m
yasnippet))
'(safe-local-variable-values
'((ispell-personal-dictionary . "../francais.dict")
(TeX-master . "../th-langage") (Package . CL-FAD)
(TeX-master . t) (Base . 10) (Package . CL-PPCRE)
(Syntax . COMMON-LISP))))do i ALSO need a use-package call?
no
BTW is this a bug in cider, or it is it really intended that every user of cider enable interrupting an infinite or long evaluation?
in my case cider-interrupt is bound to C-c C-b, while C-c C-c is bound to cider-eval-defun-at-point. Is that normal?
it could be that during my live demo, I was pressing C-c C-c to interrupt, and it was rather re-evaluating …. 😞
that JVM setting is not enabled by default because "some hardened environments forbid self-attach" (from that variable documentation)
you're right it's C-c C-b by default, must be my config
in slime (common lisp version of cider) C-c C-c is the normal way to compile and exec the current form. I don’t know whether i’ve set this in cider to have the more-or-less-same behavior, or whether that’s the default behavior.
anyway, i’ve set the elisp variable (setq cider-enable-nrepl-jvmti-agent t) and now C-c C-b seems to interrupt a running evaluation correctly. Thanks for the help.
Also, sorry for the long delays in responding. I’m a bit too distracted these few days.
Can I do something in a global UncaughtExceptionHandler that will reliably cause a stacktrace to show up in CIDER, no matter what thread threw the exception? (either in the REPL buffer or a separate error buffer).
There is https://github.com/clojure-emacs/cider/issues/3850 to track this feature. I was planning to make a PoC sometime next month