cider 2026-02-16

I no longer seem to be able to disable CIDER's interception of *out*

I thought this should do it, but my println's are still going to the REPL buffer, not to the process stdout

(setq cider-redirect-server-output-to-repl nil)

I ended up with the old workaround

(binding [*out* (io/writer System/out)]
  (println ...))

setting that var should do it – IIRC it has to be set before you cider-connect

I had a similar issue a while back and I worked around it at the time by doing something like this at the REPL:

(cider.nrepl.middleware.out/unsubscribe-session (:session nrepl.middleware.interruptible-eval/*msg*))
It works for me now though using [nrepl "1.5.2"] and [cider/cider-nrepl "0.58.0"] Maybe confirm your cider/cider-nrepl/nrepl versions?

πŸ‘ 1

yeah that's fair, I'm probably out of date. I did restart my repl after setting the variable

I don't know if/when anything around this has changed recently though. It's definitely a long while since I had an issue with it

Had a quick look and the relevant client/middleware code both haven't changed in ~years. Just to check – your printing code is relying on some load-time captured value of *out*?

If you're just using e.g. println at the REPL and you want the output to go somewhere else then the relevant setting is cider-interactive-eval-output-destination

I was just doing a bare println, in particular inside an add-watch. Some of the output would go to the REPL buffer, some to the terminal where clojure is running.

thanks for looking into it, the workaround works for now.

πŸ‘ 1

ah, I thought the client wasn't using the new forward-system-output op from there yet

Hmm, now I started to wonder whether you might be right, as I don’t recall if we made the change already or not. πŸ˜… I’ll have to consult the code.

I'm guessing you're seeing the impact of https://github.com/nrepl/nrepl/pull/393

We've been gradually upstreaming some things from cider-nrepl to nrepl.

πŸ‘ 1

Hello Arne! Please specify, do you need to disable redirecting of *out* or System/out?

*out*, I want my printlns to go to my terminal (jvm process stdout), and not to nREPL/CIDER/`*cider-repl*`. It seems System/out is not being intercepted, hence why binding [*out* (io/writer System/out)] works as a workaround

And (setq cider-redirect-server-output-to-repl nil) used to prevent *out* being redirected, right? And it no longer does?

if you're using add-watch then I wonder if sometimes the watch is being called with the load-time binding of *out* (either something captures its value at load time or maybe it's called from a non-nrepl thread) and sometimes with a REPL-time binding of *out*