This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-06-24
Channels
- # announcements (1)
- # beginners (78)
- # cider (19)
- # circleci (4)
- # clojure (27)
- # clojure-denmark (3)
- # clojure-europe (29)
- # clojure-gamedev (1)
- # clojure-madison (1)
- # clojure-nl (2)
- # clojure-norway (37)
- # clojure-sweden (5)
- # clojure-uk (4)
- # core-typed (45)
- # datahike (5)
- # fulcro (1)
- # graalvm (17)
- # gratitude (1)
- # hyperfiddle (3)
- # lsp (17)
- # malli (1)
- # off-topic (3)
- # pathom (11)
- # polylith (7)
- # re-frame (13)
- # releases (1)
- # ring (20)
- # scittle (21)
- # specter (4)
- # tools-build (8)
- # xtdb (10)
- # yamlscript (7)
i’m starting a cider repl in emacs with cider-jack-in-clj
.
i’m trying to figure out how to get jvm shutdown hooks to run when i close that repl using cider-quit
.
what i’ve figured out is that cider-quit
is calling the elisp command delete-process
which sends a SIGKILL
signal to the running jvm and this prevents the jvm from shutting down gracefully.
what’s the reasoning behind this behaviour and how could i approach changing it?
Good find!
Yes, I see that we use delete-process
instead of, for instance, interrupt-process
.
I don't know the original reasoning but it could be to ensure a snappy experience - else imagine that a project has no (shutdown-agents)
call so the JVM may take up to a minute to gracecully shut down.
I think that a PR that introduced an alternative backed by a defcustom and/or prefix argument would be welcome.
Common practice is to send SIGTERM and if the process doesn’t shut down in 10 seconds then SIGKILL; docker does that for instance
i see. having to wait for a minute when (shutdown-agents)
is missing would be a bad default experience.
would it be feasible to change the default behaviour, for example by injecting a shutdown-hook that calls (shutdown-agents)
before calling interrupt-process
?
That would be overly complex if not intrusive, from intuition
The way I'd do this is to introduce a defcustom say defcustom cider-graceful-shutdown-timeout nil
With its default value, we keep the current behavior as-is
With a value of 10, we wait up to 10 seconds as @U06BE1L6T describes
...This approach has the nice side-effect of 'hiding' the change under a feature flag - I try for changes to be introduced gradually so that we have a chance to catch bugs
After I run cider-jack-in
I am getting this warning:
WARNING: CIDER 1.15.0 requires cider-nrepl 0.49.0, but you're currently using cider-nrepl 0.28.5. The version mismatch might break some functionality! (More information)
I can see that in the classpath it is indeed using cider-nrepl 0.28.5
, how can I enforce that it uses the latest cider-nrepl version?
Also the link on More information
leads me to a Not Found page: https://docs.cider.mx/cider/1.15/troubleshooting.html#cider-complains-of-the-cider-nrepl-version.> Also the link on More information
leads me to a Not Found page: https://docs.cider.mx/cider/1.15/troubleshooting.html#cider-complains-of-the-cider-nrepl-version.
Looks like we forgot some "doc ops", will deploy in a bit
> I can see that in the classpath it is indeed using cider-nrepl 0.28.5
, how can I enforce that it uses the latest cider-nrepl version?
That's a Lein / tools.deps problem that we can't primarily fix, I think.
clojure -Stree
/ lein deps :tree
can help you see where the old dep comes from
Interesting, when I run clojure -Stree
I can only see cider/cider-nrepl 0.49.0
and no cider-nrepl version 0.28.5, but I stlil get the warning.
Are you using any aliases? You may need e.g. clojure -A:dev:test -Stree whatever exactly matches your real usage
Or, an easier way to debug - after jack-in, the "jack in command" should have been printed to the repl buffer Feel free to share it here
I am not using any aliases (that I know of), this is the output of when I run cider-jack-in
:
Connected to nREPL server -
;; CIDER 1.15.0 (Cogne), nREPL 0.9.0
;; Clojure 1.11.3, Java 21.0.3
;; Docs: (doc function-name)
;; (find-doc part-of-name)
;; Source: (source function-name)
;; Javadoc: (javadoc java-object-or-class)
;; Exit: <C-c C-q>
;; Results: Stored in vars *1, *2, *3, an exception in *e;
;; ======================================================================
;; If you're new to CIDER it is highly recommended to go through its
;; user manual first. Type <M-x cider-view-manual> to view it.
;; In case you're seeing any warnings you should consult the manual's
;; "Troubleshooting" section.
;;
;; Here are a few tips to get you started:
;;
;; * Press <SPC h m> to see a list of the keybindings available (this
;; will work in every Emacs buffer)
;; * Press <M-x cider-repl-handle-shortcut> to quickly invoke some REPL command
;; * Press <, s s> to switch between the REPL and a Clojure file
;; * Press <g d> to jump to the source of something (e.g. a var, a
;; Java method)
;; * Press <K> to view the documentation for something (e.g.
;; a var, a Java method)
;; * Print CIDER's refcard and keep it close to your keyboard.
;;
;; CIDER is super customizable - try <M-x customize-group cider> to
;; get a feel for this. If you're thirsty for knowledge you should try
;; <M-x cider-drink-a-sip>.
;;
;; If you think you've encountered a bug (or have some suggestions for
;; improvements) use <M-x cider-report-bug> to report it.
;;
;; Above all else - don't panic! In case of an emergency - procure
;; some (hard) cider and enjoy it responsibly!
;;
;; You can remove this message with the <M-x cider-repl-clear-help-banner> command.
;; You can disable it from appearing on start by setting
;; 'cider-repl-display-help-banner' to nil.
;; ======================================================================
;; Startup: /usr/local/bin/clojure -J-XX:-OmitStackTraceInFastThrow -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"0.9.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.28.5\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[cider.nrepl/cider-middleware\]\"\]\}\}\} -M:cider/nrepl
WARNING: CIDER 1.15.0 requires cider-nrepl 0.49.0, but you're currently using cider-nrepl 0.28.5. The version mismatch might break some functionality! (More information)
Maybe the value of cider-injected-middleware-version
has been customized? What's its value as you start Emacs (before jacking in)?
the value is 0.49.0
By the way I am using this thing called Corgi emacs: https://github.com/corgi-emacs/corgi I am not sure if this sets something regarding cider-nrepl under the hood
Maybe there's some odd mix-up, yes
Although it says ;; CIDER 1.15.0 (Cogne), nREPL 0.9.0
You could try:
• ensure with Straight.el (as used by Corgi) that the cider version is 1.15.0
• clean all .elc files recursively within your emacs directory
• restart Emacs
Cleaning all .elc files and starting Emacs again fixed the issue, now I have no warning, thank you for the help!