Fork me on GitHub
#cider
<
2024-02-08
>
skyjuice01:02:07

Hello, I'm randomly running into Lisp nesting exceeds 'max-lisp-eval-depth with several cider commands (`cider-repl-history` cider-jack-in-clj ..) . Primarily its preventing me from jacking-in, the times that I do manage to jack-in, calling an offending command kills the repl's interactivity rendering it a plain text buffer . The initial jack-in after starting or restarting emacs gives: error in process filter: Lisp nesting exceeds 'max-lisp-eval-depth' : 1601 Cider 1.13.1 (Santiago), emacs 29 native-comp.

vemv08:02:18

Personally I set (setq max-lisp-eval-depth 10000) globally. I don't remember the exact reason, but it hasn't hurt (Similarly in Clojure I set a fairly large stack size: "-Xss6144k" - it allows certain algos to complete normally) Hope it helps!

skyjuice15:02:22

thx @U45T93RA6, unfortunately I'm still getting the same errors after setting the depth to 10000. WRT the clojure stack size, does that go in the jvm opts? I tried: deps.edn

... :aliases
    {:web-dev {:extra-paths ["src/web_dev"]
               :main-opts ["-m" "web-dev.core"]
               :jvm-opts ["-Xss6144k"]}}} 

vemv15:02:54

Yes that looks correct. To be clear, I only cited it as an example of increasing the stack not being necessarily a bad practice or workaround. But it doesn't fix any Elisp issue. So, you are seeing Lisp nesting exceeds 'max-lisp-eval-depth' : 10000 now or so? (different number)

skyjuice17:02:57

got it, yep the new error is: error in process sentinel: Lisp nesting exceeds 'max-lisp-eval-depth' : 10001`

vemv18:02:15

Doesn't M-x toggle-debug-on-error cause a stacktrace to pop up?

skyjuice18:02:03

This was thrown by calling recentf on a .clj file with toggle-debug.. enabled (Warning Worlds largest stacktrace ahead) https://cryptpad.fr/code/#/2/code/view/b3tQMLkvpQ91TvGXAqeuLZgnIeahNJV4pZyq5Mc19LA/embed/

vemv19:02:31

Thanks! We got a lead :) It doesn't immediately bring something to mind. Do you have any cider hooks set up in your personal emacs config?

skyjuice19:02:13

Yep there are few hooks in the config. Here's my clj-mode and cider mode setups clojure-mode:

(use-package clojure-mode
    :ensure t
    :hook (clojure-mode . hs-minor-mode)
    :mode (("\\.clj\\'" . clojure-mode)
	   ("\\.edn\\'" . clojure-mode))
    :config
    (setq clojure-align-forms-automatically t))

    ;;Prevent error: Lisp nesting exceeds 'max-lisp-eval-depth 
    (setq max-lisp-eval-depth 10000)
Cider:
(use-package cider
      :ensure t
      :demand t
      :config
	    (add-hook 'cider-mode-hook 'cider-repl-history-mode)
	    (add-hook 'cider-repl-mode-hook #'corfu-mode)
	    (add-hook 'cider-mode-hook #'corfu-mode)
	    (add-hook 'cider-repl-mode-hook #'paredit-mode)) 

vemv19:02:18

It's definitely (add-hook 'cider-mode-hook 'cider-repl-history-mode) :)

🙏 1
vemv19:02:44

In the stacktrace you can see how they call each other ad nauseam

🙌 1
skyjuice23:02:04

That was the exactly the problem, thanks @U45T93RA6 , I finally have a civilized repl again 🥲

🙌 1
frozenlock13:02:19

I was under the impression that CIDER had the ability to load a library using the sideloader. (One that is not declared in project.clj or deps.edn.) I'm unable to find docs/articles related to this. Am I misremembering?

vemv14:02:39

It's https://cljdoc.org/d/nrepl/nrepl/1.1.0/api/nrepl.middleware.sideloader which has some integration with cider (please grep it in https://github.com/clojure-emacs/cider/blob/master/CHANGELOG.md) Personally I've never used it. At this point it might be wise to simply wait until Clojure 1.12 add-lib

vemv14:02:29

...clj-refactor.el had a different form of this many years ago. It broke with newer JDKs

frozenlock14:02:02

Ah I see, thank you very much!

bozhidar06:02:06

nREPL supports sideloading indeed, but I don’t recall whether we fully implemented this in CIDER.

bozhidar06:02:27

I recall I wrote the POC and then Arne did some work for sideloading middleware https://github.com/clojure-emacs/cider/pull/3044/files

bozhidar06:02:19

That’s the main ticket https://github.com/clojure-emacs/cider/issues/3037, which seems we never wrapped

bozhidar07:02:20

It’s a pity, though, as I still think the sideloading approach has some merits over add-lib.