syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

org-babel doesn't load correctly #3439

Closed CestDiego closed 7 years ago

CestDiego commented 8 years ago

When trying to eval a python source block I get that I have not defined a babel execute for python, but then I go to my config and I try to execute this:

    (org-babel-do-load-languages
     'org-babel-load-languages
     '((R . t)
       (emacs-lisp . t)
       (python . t)
       (sh . t)
       (haskell . t)
       (js . t)
       (latex . t)
       (gnuplot . t)
       (C . t)
       (sql . t)
       (ditaa . t)
       ))

and I get this backtrace:

Debugger entered--Lisp error: (void-variable org-babel-safe-header-args)
  (append org-babel-safe-header-args (quote (:width :height :bg :units :pointsize :antialias :quality :compression :res :type :family :title :fonts :version :paper :encoding :pagecentre :colormodel :useDingbats :horizontal)))
  (defconst ob-R-safe-header-args (append org-babel-safe-header-args (quote (:width :height :bg :units :pointsize :antialias :quality :compression :res :type :family :title :fonts :version :paper :encoding :pagecentre :colormodel :useDingbats :horizontal))) ("/home/jarvis/.emacs.d/elpa/org-20151005/ob-R.elc" . 995))
  require(ob-R)
  #[(pair) "A\303@!\211\203\304\305\306    P!!\202%\307\305\310    P!!\210\307\305\311 P!!*\207" [pair lang active symbol-name require intern "ob-" fmakunbound "org-babel-execute:" "org-babel-expand-body:"] 5]((R . t))
  mapc(#[(pair) "A\303@!\211\203\304\305\306   P!!\202%\307\305\310    P!!\210\307\305\311 P!!*\207" [pair lang active symbol-name require intern "ob-" fmakunbound "org-babel-execute:" "org-babel-expand-body:"] 5] ((R . t) (emacs-lisp . t) (python . t) (sh . t) (haskell . t) (js . t) (latex . t) (gnuplot . t) (C . t) (sql . t) (ditaa . t)))
  org-babel-do-load-languages(org-babel-load-languages ((R . t) (emacs-lisp . t) (python . t) (sh . t) (haskell . t) (js . t) (latex . t) (gnuplot . t) (C . t) (sql . t) (ditaa . t)))
  eval((org-babel-do-load-languages (quote org-babel-load-languages) (quote ((R . t) (emacs-lisp . t) (python . t) (sh . t) (haskell . t) (js . t) (latex . t) (gnuplot . t) (C . t) (sql . t) (ditaa . t)))) nil)
  eval-last-sexp-1(nil)
  #[257 "\204\303!\207   \303!\n)B\211A    =\204\211A\211@\207" [eval-expression-debug-on-error eval-last-sexp-fake-value debug-on-error eval-last-sexp-1] 4 2422445 "P"](nil)
  ad-Advice-eval-last-sexp(#[257 "\204\303!\207  \303!\n)B\211A    =\204\211A\211@\207" [eval-expression-debug-on-error eval-last-sexp-fake-value debug-on-error eval-last-sexp-1] 4 2422445 "P"] nil)
  apply(ad-Advice-eval-last-sexp #[257 "\204\303!\207    \303!\n)B\211A    =\204\211A\211@\207" [eval-expression-debug-on-error eval-last-sexp-fake-value debug-on-error eval-last-sexp-1] 4 2422445 "P"] nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)
robbyoconnor commented 8 years ago

:eyes:

izahn commented 8 years ago

@CestDiego The error is coming from ob-R.el, which is not needed for python.

    (org-babel-do-load-languages
     'org-babel-load-languages
     '((python . t)))

(or even easier, just (require 'ob-python)) should be enough to get python code blocks working.

As for the actual bug encountered, it looks similar to a known problem in org-mode. See https://www.mail-archive.com/emacs-orgmode@gnu.org/msg98888.html and https://www.mail-archive.com/emacs-orgmode@gnu.org/msg98762.html. Make sure your packages are up to date. If packages are up to date reinstalling org-plus-contrib might fix it. FWIW, I have org-babel configured in .spacemacs by adding

    (eval-after-load 'org
      (lambda()
        (require 'ess-site)
        (require 'ob-R)
        (require 'ob-emacs-lisp)
        (require 'ob-latex)
        (require 'octave)
        (require 'ob-python)
        (require 'ob-sql)
        (require 'ob-shell)
        (require 'ob-sqlite)
        (require 'ob-julia)
        (require 'ob-perl)
        (require 'ob-org)
        (require 'ob-awk)
        (require 'ob-sed)
        (require 'ob-css)
        (require 'ob-js)
        (require 'ob-stata)
        (setq org-export-babel-evaluate nil)
        (setq org-startup-indented t)
        ;; increase imenu depth to include third level headings
        (setq org-imenu-depth 3)
        ;; Set sensible mode for editing dot files
        (add-to-list 'org-src-lang-modes '("dot" . graphviz-dot))
        ;; Update images from babel code blocks automatically
        (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
        (setq org-src-fontify-natively t)
        (setq org-src-tab-acts-natively t)
        (setq org-confirm-babel-evaluate nil)))

to the dotspacemacs/user-init section. (You may or may not want all my setting of course). This works correctly for me on both the master and develop branches.

zilongshanren commented 8 years ago

@CestDiego Open ob-R.el and do byte-compile-file to recompile the ob-R.el and the problems is gone.

CestDiego commented 8 years ago

@zilongshanren this didn't fix it :(

liangwang commented 8 years ago

Try my workaround at the end of #3314.

CestDiego commented 8 years ago

I did this now:

added (org-babel :location local) and

(defun org-cestdiego/init-org-babel ()
  (use-package org-babel
    :init
    (org-babel-do-load-languages
     'org-babel-load-languages
     '((R . t)
       (emacs-lisp . t)
       (python . t)
       (sh . t)
       (haskell . t)
       (js . t)
       (latex . t)
       (gnuplot . t)
       (C . t)
       (sql . t)
       (ditaa . t)
       ))
    ))

To my private layer, and now it works, thank you @liangwang for the solving of the error.

paynito commented 7 years ago

per @zilongshanren 👍 cd ~/.emacs.d/elpa/org-20160926 ; rm ob-R.elc caveats: change the date in the folder name.

jackkamm commented 7 years ago

I have this problem as well, on OSX and Archlinux, emacs 24 and 25, and it is due to ob-R.elc. The solutions given by @zilongshanren and @paynito both worked for me. Calling spacemacs/recompile-elpa also works to fix the problem.

TheBB commented 7 years ago

Closing in favor of https://github.com/syl20bnr/spacemacs/issues/4618