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?

  • 1
    Do you have the same issues, when you use org-babel-execute-src-block ? – bertfred Nov 5 '16 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 Nov 5 '16 at 13:51
  • @bertfred results in same behaviour as <kbd>C-c C-c</kbd>. – rrogg Nov 5 '16 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 Nov 11 '16 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 Apr 7 '17 at 14:10
42

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.

  • Awesome I had the exact same Issue, and I couldn't understand why it wasnt working – Joafigue Nov 7 '16 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 Nov 21 '16 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.

  • 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 May 17 '18 at 17:20
  • 1
    This worked for me on spacemacs – prasad Jan 5 at 17:59
4

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

  • Reinstalling the same version or a later one? – JeanPierre Nov 6 '16 at 8:48
  • remove current version and install latest from Melpa – zeltak Nov 6 '16 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)))
  • I'd generally recommend against adding any kind of require to one's init file, because it slows down startup. – Stefan Jan 27 '18 at 21:39
  • I did not know that until now. Thanks for the advice! – Takuya Ebata Jan 29 '18 at 2:43

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.