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?

Chakravarthy Raghunandan
  • 3,132
  • 2
  • 18
  • 42
rrogg
  • 595
  • 1
  • 4
  • 7
  • 1
    Do you have the same issues, when you use `org-babel-execute-src-block` ? – bertfred Nov 05 '16 at 13:36
  • Reinstall org-mode (delete org folder from `.emacs.d/elpa` first), that issue may have been solved already: http://lists.gnu.org/archive/html/emacs-orgmode/2016-11/msg00054.html – VanLaser Nov 05 '16 at 13:51
  • @bertfred results in same behaviour as C-c C-c. – rrogg Nov 05 '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 07 '17 at 14:10

6 Answers6

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.

erikstokes
  • 12,686
  • 2
  • 34
  • 56
  • Awesome I had the exact same Issue, and I couldn't understand why it wasnt working – Joafigue Nov 07 '16 at 04: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 04: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.

ephsmith
  • 103
  • 2
4

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

zeltak
  • 1,685
  • 11
  • 25
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
Stefan
  • 26,154
  • 3
  • 46
  • 84
rdcdr
  • 63
  • 5
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)))
Drew
  • 75,699
  • 9
  • 109
  • 225