2

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
#+END_SRC

#+RESULTS:
|           |
| /bin/bash |

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

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

#+RESULTS:
|         |
| /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 at 2:32
1

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")))
    (save-window-excursion
      (or (org-babel-comint-buffer-livep session)
          (progn
        (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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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