Fork me on GitHub
#cider
<
2023-12-19
>
andrea.crotti14:12:10

does anyone have magic code to change the cider banner to something different when connecting to live repls? And also any idea why just adding this to my .dir-locals.el file

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((nil . ((cider-repl-display-help-banner . "THIS IS PRODUCTION, BE VERY CAREFUL"))))
does not seem to have any effect?

👀 1
andrea.crotti14:12:03

by no effect I mean that if I start a repl from a buffer (where that variable is set to that string)

andrea.crotti14:12:10

I doin't see any banner when the repl starts up

andrea.crotti14:12:22

just

;; Connected to nREPL server - 
;; CIDER 1.13.0-snapshot (package: 20231204.843), nREPL 1.0.0
;; Clojure 1.11.1, Java 17.0.9
;;     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;
user> 

vemv14:12:33

that var only works as a boolean flag, from what I see

andrea.crotti14:12:40

so the banner is fixed from cider-repl--help-banner ()

andrea.crotti14:12:51

mm ok I was sure it was possible to override it for some reason

andrea.crotti14:12:00

I guess I can just redefine that function in theory

andrea.crotti14:12:45

a bit hacky though

vemv14:12:33

Yes. It would SGTM to extract the string to a defcustom, please create an issue so that others can share their opinion

diba19:12:54

anyone know if it’s possible to have it such that when cider-pprint-eval-last-sexp throws an error it doesn’t close the *cider-result* buffer?

vemv20:12:29

I've worked on cider-pprint-eval-last-sexp error handling quite recently, feel free to create an issue explaining the use case

andrea.crotti21:12:58

is anyone else using nRepl for live repls into prod/dev? when using a local repl we don't have to specify the version of cider-nrepl in the dependencies, so it's always in sync with what we have installed locally, but that would not be true for the remote repl. So do I just add the cider-nrepl dependency anyway and when used locally it will just be overridden (by the jack-in process?)

andrea.crotti21:12:11

I guess there is no way to make the remote one sync with your local env anyway

andrea.crotti21:12:42

or are people using socket/prepls maybe for prod/dev repls?

vemv22:12:29

I wouldn't include cider-nrepl into a production app - it can bloat the dependency tree and create a variety of unforeseen behaviors. However including nrepl/repl, and spawning a nrepl server from there, is more minimalistic and quite usual. You wouldn't add cider-nrepl, refactor-nrepl or other pieces of middleware in this nrepl server. When connecting to it from cider, you'd get a warning about missing middleware, which is perfectly fine to ignore. (You'll get a variety of basic features working, but others won't. Normally we fail-fast on absence of middleware support, so it's all pretty clear to end users)

vemv22:12:12

...There are alternative patterns as well, for instance leaving the prod app entirely untouched and create a 'sidecar' JVM process with cider-nrepl (all of it). This way, you get nice extra features (cider-inspect can be definitely handy for production) without the side-effects, and if something goes terribly wrong, process isolation would save you.

jakemcc23:12:34

What @vemv describes is what we do (include nrepl as a dep, etc). It works well for us.

andrea.crotti09:12:13

ah ok interesting

andrea.crotti09:12:39

any examples o f the sidecar JVM approach as well?

andrea.crotti09:12:52

(ns system
  (:require
   [cider.nrepl :refer [cider-nrepl-handler]]
   [clojure.core.server :as server]
   [integrant.core :as ig]
   [io.pedestal.http :as http]
   [nrepl.server :as nrepl]))


(defmethod ig/init-key ::nrepl-server [_ {:keys [port]}]
  (assert (some? port), "Missing port")
  (println "Starting nrepl server on port " port)
  (nrepl/start-server :port port
                      :bind "0.0.0.0"
                      :handler cider-nrepl-handler))

andrea.crotti09:12:05

ah and actually I was starting the nrepl server with cider-nrepl-handler

andrea.crotti09:12:00

so I guess I have to change that if I should not include cider-nrepl as dependency

👍 1
andrea.crotti10:12:57

yeah ok that was easy ,just had to remove that and it fallsback to the default handler

vemv11:12:41

> any examples o f the sidecar JVM approach as well? (edited) Not that I know of. Maybe I'd simply make sure a git clone of the project is available, so that I can spawn a repl on demand with a simple command like lein repl But sky is the limit 🙂 one could also devise a detailed Dockerfile

andrea.crotti11:12:04

mm yeah I probably would not do that

andrea.crotti11:12:14

we just keep the docker images minimal with just the jdk installed

andrea.crotti11:12:31

better to just include nrepl in the dependencies then