I am trying to run clojure code from my org file in order to do some literate programming.

What is not working:

When I execute the source code block I get No output produced.

Sample src code block

#+begin_src clojure
(+ 2 2)
#+end_src clojure

What is working:

  1. cider-jack-in is working and I am able to execute code in the nREPL
  2. I am able to execute code from a .clj file



Emacs 25.1 using Spacemacs

Org-Mode 9.0.5

Org babel configuration

(defun dotspacemacs/user-config ()
  (require 'ob)
  (require 'ob-clojure)
  (require 'paredit)
  (require 'org-babel-clojure)
  (setq org-babel-clojure-backend 'cider)
  (require 'cider)
   '((clojure . t)))

Please let me know if you need any other information

4 Answers 4


I'm seeing he same issue. In a little digging, I think I've identified the problem. However, not sure who this should be reported to.

The problem is in the org-babel-execute:clojure function. This function has the following bit of code

(setq result
     expanded (cider-current-connection) (cider-current-session))
    (if (or (member "output" result-params)
        (member "pp" result-params))

The problem is in the call to nrepl-sync-request:eval. The documentation states for this function

(nrepl-sync-request:eval INPUT CONNECTION &optional NS)

Send the INPUT to the nREPL server synchronously. The request is dispatched via CONNECTION. If NS is non-nil, include it in the request.

Note the last optional argument NS. This is supposed to be a clojure namespace. However, the org-babel-execute:clojure function is calling this function with the output from cider-current-session, which returns a unique ID representing the current session. As a result, the call is returning a data structure with an error and no output (perhaps some error handling is required). The returned result is

(dict status (namespace-not-found done error done state state) id 17 session 43e9fd6c-82ed-49fe-9624-0cfc6f56f8b1 changed-namespaces (dict) repl-type cljclj)

Note the namespace-not-found

Either the argument should be a call to (cider-current-ns) or perhaps it should just be left out as I don't see how you can pass the namespace as part of the block evaluation.

EDIT: here is a simple patch which appears to fix the problem. Generated against current head of org git repo

 lisp/ob-clojure.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index d407105..e542a29 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -44,6 +44,7 @@

 (declare-function cider-current-connection "ext:cider-client" (&optional type))
 (declare-function cider-current-session "ext:cider-client" ())
+(declare-function cider-current-ns "ext:cider-client" ())
 (declare-function nrepl--merge "ext:nrepl-client" (dict1 dict2))
 (declare-function nrepl-dict-get "ext:nrepl-client" (dict key))
 (declare-function nrepl-dict-put "ext:nrepl-client" (dict key value))
@@ -118,7 +119,7 @@ using the :show-process parameter."
               (nrepl-sync-request:eval expanded
-                       (cider-current-session))))
+                       (cider-current-ns))))
           (setq result
              (nrepl-dict-get response
@@ -153,7 +154,7 @@ using the :show-process parameter."
        ;; Update the status of the nREPL output session.
        (setq status (nrepl-dict-get response "status")))
-         (cider-current-session))
+         (cider-current-ns))

         ;; Wait until the nREPL code finished to be processed.
         (while (not (member "done" status))

Also sent the patch to the emacs-orgmode list

  • So are you saying we should edit the function and replace it with (cider-current-ns)? And if so, where can I find that function?
    – Jeel Shah
    Mar 2, 2017 at 15:39
  • 1
    I'm saying that to make ob-clojure work, either the call to (cider-current-session) needs to be dropped or it needs to be replaced with (cider-current-ns). The (cider-current-ns) is part of the cider library (along with cider-current-connection) and (cider-current-session)). Either you need to edit the function or wait until someone updates it upstream, but as it stands now, it does not work. I have reported this on the emacs-org list, but no response yet.
    – Tim X
    Mar 2, 2017 at 20:10
  • Your solution is working perfectly. My ob-clojure was a bit older so I pulled the newest ones, made the relevant changes and it works! Thank you so much! I wish you had answered a few days before! I would definitely given the bounty to you. :) Thanks!
    – Jeel Shah
    Mar 3, 2017 at 18:08
  • 1
    As of 3 Jun 2017, Emacs 25.1.1, org 9.0.7, spacemacs 0.200.9, this fix is still not in when I did a fresh clone of spacemacs develop branch and a wipe of my elpa directory. I still needed to purge org directories to get any code-block eval to work find ~/.emacs.d/elpa/org* -name "*elc" -delete, then manually apply the patch above. The good news is that the patch works today.
    – Reb.Cabin
    Jun 3, 2017 at 15:20
  • To be honest, I don't understand the structure of the org git branches and how they relate to the org-plus-contrib package. I know the patch was committed into the main org repository because I did a pull and say the commit. No idea how such patches get into the package files.
    – Tim X
    Jun 9, 2017 at 2:17

You need to have header arguments in the block telling org-babel what you want to include in the results produced - result of evaluation or output to stdout or both. In your case, there is no output that the evaluation of (+ 1 1) produces. Try (println (+ 1 1)).

#+name: Lazy Sequences in Clojure
#+begin_src clojure
 (def a-lazy-sequence (cons 1 (lazy-seq (cons (+1 2) ()))))

#+name: List comprehensions in Clojure
#+begin_src clojure :results output
 (println (str (for [x (range 3)
                     y #{:a :b :c}]
                 [x y])))


#+RESULTS: List comprehensions in Clojure
 : (c l o j u r e . l a n g . L a z y S e q @ e a a 0 1 c e 7)


#+begin_src clojure :results value
(+ 2 2)
#+end_src clojure

which prints the returned value instead of output.

  • 1
    Still does not work, The message area shows "Code block returned no value". Feb 23, 2017 at 6:38

This problem is not necessarily specific to Spacemacs.

While the OP may have implicitly sought a solution within Spacemacs, this seems like a good place to mention another alternative (esp. for non-Spacemacs users who are experiencing the same problem after updating some piece of their emacs/org-mode configuration, which is what happened to me).

After trying many re-installs of various emacs and org versions, I finally found that Aquamacs (!) and Org 9.0.5 (downloaded as a tar.gz as instructed on http://orgmode.org/) succeeded in getting around the code block produced no output problem this poster also experienced.

While Aquamacs may not be a long-term solution for everybody, it certainly can help others who are highly dependent on using org-babel with clojure get around this problem until the above solution is fully recognized and implemented.

The version of emacs used by Aquamacs as of this March 9 2017 is:

Aquamacs 3.3 GNU Emacs 25.1.1 (x86_64-apple-darwin14.1.0, NS appkit-1344.72 Version 10.10.2 (Build 14C109)) of 2016-09-19 on 24a02dbf6b34ae061ef4df89f15bfbc5d3ed497e

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.