45

My Emacs config lives inside of a .org file from which I tangle source blocks to a .el file. I could evaluate source blocks with C-c C-c

Today I updated to org-mode version 9 from org elpa and now evaluating a source block like

#+BEGIN_SRC emacs-lisp :tangle yes
(setq org-export-coding-system 'utf-8)
#+END_SRC

with C-c C-c prints the following message

Evaluation of this emacs-lisp code-blockis disabled.

In my init.el I have already defined the languages for org-babel:

(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
  (org . t)
  (sh . t)))

If I load the stock Emacs version of org-mode I can tangle with C-c C-c as expected. I could not find any changes regarding this in the changelog for org-mode 9.

How to enable evaluation of code-blocks in org-mode 9?

5
  • 1
    Do you have the same issues, when you use org-babel-execute-src-block ?
    – bertfred
    Commented Nov 5, 2016 at 13:36
  • Reinstall org-mode (delete org folder from .emacs.d/elpa first), that issue may have been solved already: lists.gnu.org/archive/html/emacs-orgmode/2016-11/msg00054.html
    – VanLaser
    Commented Nov 5, 2016 at 13:51
  • @bertfred results in same behaviour as <kbd>C-c C-c</kbd>.
    – rrogg
    Commented Nov 5, 2016 at 14:17
  • 1
    I had the same issue and had to hard-reinstall (something like this but I don't remember because I was frustrated and didn't take notes: uninstall, quit emacs, delete from elpa, start emacs, install from elpa, quit emacs, start emacs) )
    – amitp
    Commented Nov 11, 2016 at 17:28
  • I'm very sad to report that this problem seems to have returned. The following is from a fresh installation into a bare machine; evaluation of source blocks is disabled, and I don't see how to enable it. Org-babel seems to be dead. (emacs-version) "GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2016-09-17" (org-version) "9.0.5"
    – Reb.Cabin
    Commented Apr 7, 2017 at 14:10

6 Answers 6

47

I think this problem is caused by the change of org-babel-check-confirm-evaluate from a macro to a function. If you have org-mode (and thus the old macro) loaded when you compile the new code, it sees the old macro instead of the new function.

As others have pointed out uninstalling org-mode restarting Emacs (without loading org-mode) and reinstalling will fix the problem. You can also delete the compiled .elc files and recompile with byte-recompile-directory.

2
  • Awesome I had the exact same Issue, and I couldn't understand why it wasnt working
    – Joafigue
    Commented Nov 7, 2016 at 4:23
  • 1
    Yes, this is a good explanation and solution. But I found the solution below, by @בנימן הגלילי much easier than uninstalling/reinstalling org-mode.
    – modulitos
    Commented Nov 21, 2016 at 4:18
38

To elaborate on @erikstokes:

rm ~/.emacs.d/elpa/ORGDIRNAME/*.elc

where ORGDIRNAME is the name of the core ogrmode directory. Restart emacs and you can now run org-babel code blocks.

2
  • 1
    This worked for me with org-9.1.13. It's quicker than re-installing. Note that the org directory name will likely differ.
    – ephsmith
    Commented May 17, 2018 at 17:20
  • 1
    This worked for me on spacemacs
    – prasad
    Commented Jan 5, 2019 at 17:59
4

for me uninstalling the org-plus-contrib package and reinstalling it solved it.

2
  • Reinstalling the same version or a later one?
    – JeanPierre
    Commented Nov 6, 2016 at 8:48
  • remove current version and install latest from Melpa
    – zeltak
    Commented Nov 6, 2016 at 10:42
3

On Emacs 25.2 (9.0) and using org-plus-contrib:

  • org-babel-execute-src-block gave me the same error as C-c C-c
  • deleting the .emacs.d/elpa folder and reinstalling did not fix it
  • but M-x package-delete [RET] org-plus-contrib and reinstalling with M-x package-install [RET] org-plus-contrib DID fix it
0

By default, Org enables only emacs-lisp ‘src’ code blocks for execution.

org-babel-no-eval-on-ctrl-c-ctrl-c variable can be used to remove code block execution from "C-c C-c" keybinding.

-1

I think you should add following code in your .emacs.d/init.el.

;; ditaa
(require 'ob-ditaa)
(setq org-confirm-babel-evaluate nil)
(setq org-ditaa-jar-path
  "/path/to/ditaa-0_10.jar")
(org-babel-do-load-languages
  'org-babel-load-languages
  '((ditaa . t)
    (dot . t)))
2
  • I'd generally recommend against adding any kind of require to one's init file, because it slows down startup.
    – Stefan
    Commented Jan 27, 2018 at 21:39
  • I did not know that until now. Thanks for the advice! Commented Jan 29, 2018 at 2:43

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.