I would like to use the session feature for bash source blocks, and receive the error message.

No org-babel-initiate-session function for bash!

A simple code is shown below. The code can be executed through C-cC-c. Yet I received the error message when pressing C-cC-vz.

#+BEGIN_SRC bash :session *bash*
echo $0

|           |
| /bin/bash |

Interestingly, C-c C-v z works for sh source block.

#+BEGIN_SRC sh :session *sh*
echo $0

|         |
| /bin/sh |

I use doom emacs, and the vanilla configuration for both org-mode and org-babel. Anyone knows what the potential issues are.

  • Wow!! Thanks for asking this question!! I didn't know about C-c C-v z, cool!!
    – Melioratus
    Mar 7, 2020 at 2:32

2 Answers 2


I think you uncovered a bug or something fell through the cracks when ob-shell.el was built.
Please submit bug report to org-mode repo.

Below is a temporary workaround

  1. Execute the missing org-babel-bash-initiate-session function definition below:
(defun org-babel-bash-initiate-session (&optional session _params)
  "Initiate a session named SESSION according to PARAMS."
  (when (and session (not (string= session "none")))
      (or (org-babel-comint-buffer-livep session)
        (shell session)
        ;; Needed for Emacs 23 since the marker is initially
        ;; undefined and the filter functions try to use it without
        ;; checking.
        (set-marker comint-last-output-start (point))
        (get-buffer (current-buffer)))))))

Note: I just copied org-babel-sh-initiate-session definition from ob-shell.el and changed -sh- to -bash-.

  1. Execute bash SRC again with C-c C-c.

  2. Use C-c C-v z.

Thank you for asking your question!

The answer code was tested using:
emacs version: GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10)
org version: 9.1.2


As another option, I usually list bash for my "shell script" source blocks, I am simply aliasing the initiate session function from sh:

(defun org-babel-bash-initiate-session (&optional session _params)
  "Initiate a bash/sh session named SESSION according to PARAMS."
  (org-babel-sh-initiate-session session _params))

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.