Hello,

ob-clojure-eval-with-cider keeps only "root-ex", "ex" or "out" from the nREPL 
reply and discards "err".  An evaluation that reports its failure on "err" 
alone then yields nil, and Babel says "Code block produced no output". With 
":results replace", that empty result also overwrites the block's previous 
result.

This has been hitting me the hardest on ClojureScript.  When shadow-cljs has no 
JS runtime attached, it writes "No available JS runtime" to "err" with no 
exception, then every ClojureScript block fails silently while the CIDER REPL 
shows the error.

Reproduction, with any nREPL server (babashka shown):

  1. bb nrepl-server 1667
  2. M-x cider-connect-clj RET localhost RET 1667 RET
  3. (setq org-babel-clojure-backend 'cider)
  4. In an Org buffer, C-c C-c on:

       #+begin_src clojure :results output
       (binding [*out* *err*] (println "boom"))
       #+end_src

Expected: a result of "boom".
Actual: "Code block produced no output"; the reply was
{"err" "boom\n"} with no "out", "ex" or "root-ex".

Suggested fix: fall back to "err" last, so a block that also printed to
"out" still shows that:

  (or (nrepl-dict-get response "root-ex")
      (nrepl-dict-get response "ex")
      (nrepl-dict-get response "out")
      (nrepl-dict-get response "err"))

Versions: Org 9.8.9, Emacs 31.1.50 (emacs-mac port), CIDER 2.1.0-snapshot.
The code is unchanged on main as of 30b4404a9.

Cheers

--tmk

Reply via email to