Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org-Mode Evaluation of code disabled #7641

Closed
atrifex opened this issue Nov 3, 2016 · 60 comments
Closed

Org-Mode Evaluation of code disabled #7641

atrifex opened this issue Nov 3, 2016 · 60 comments

Comments

@atrifex
Copy link

atrifex commented Nov 3, 2016

I am trying to run code as a part of org-mode's code blocks. However, it keeps saying that evaluation of code-blocks is disabled. I am not sure where to go to turn this option on. Please let me know. Thank you in advance.

@TheBB
Copy link
Collaborator

TheBB commented Nov 3, 2016

http://orgmode.org/manual/index.html

@atrifex
Copy link
Author

atrifex commented Nov 3, 2016

I actually looked through this page.

I am currently doing the following in my user-config()

  (with-eval-after-load 'org
    (require 'ob-python)
    (org-babel-do-load-languages
     'org-babel-load-languages
     '((C . t)
       (python . t)))
  )

However, this doesn't seem to change anything.

@LemmingAvalanche
Copy link
Contributor

I was able to get Python to work.

In my dotspacemacs/user-init:

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

So I didn’t use the with-eval-after-load bit.

I also included the Python layer in dotspacemacs/layers.

Then I executed org-babel-execute-src-block while point was inside the source
block below:

#+BEGIN_SRC python
import time
print("Hello, today's date is %s" % time.ctime())
print('Two plus two is')
return 2 + 2
#+END_SRC

#+RESULTS:
: 4

I get prompted about whether I want to execute the code each time I execute that
function.

Could you try the above? Then try with C if that works.

@atrifex
Copy link
Author

atrifex commented Nov 3, 2016

It did help with that. However, for some reason the bullets just appear as , *, ***. This is not a big deal however cuz i am just manually able to turn them on with little to no effort. Thank.

@LemmingAvalanche
Copy link
Contributor

@TheBB it seems that this can be closed.

@bmag bmag closed this as completed Nov 3, 2016
@agzam
Copy link
Contributor

agzam commented Nov 4, 2016

Let's re-open this issue, something definitely not right, in org 9.0 you have to load explicitly for every language you want to use? Every language I'm trying not working. lua (which supposed to be added in 9.0), javascript, bash, etc.

and ob-http (which is part of restclient layer) does not work at all - babel complains 'no such language mode: http-mode

@bmag
Copy link
Collaborator

bmag commented Nov 4, 2016

@agzam it seems the issue has been resolved for @atrifex so I closed it. I don't use org-babel and I'm not aware of the differences with Org 9.0, can you explain the bug using the usual template please?

@bmag bmag reopened this Nov 4, 2016
@agzam
Copy link
Contributor

agzam commented Nov 4, 2016

@TheBB it was kinda expected - things to break due to org-mode 9.0. Maybe we need a separate issue or maybe each one should be treated individually - it's up to you guys, but there are couple of things that appear to be broken at the moment (prob. there is more, but that's what I can see):

  • at Emacs startup, warning:

    Error (use-package): org post-:config hook: Unknown keyword: :export-block

  • eval of org-babel languages doesn't work out of the box anymore, except for emacs-lisp, so if in org-mode you make something like:

      #+BEGIN_SRC shell
      ls
      #+END_SRC
    

and then C-c C-c to evaluate that piece, it would not do anything so EVERY single language (except emacs-lisp) now has to be explicitly loaded, e.g.:

(org-babel-do-load-languages
 'org-babel-load-languages
 '((shell . t)
   (js . t)
   (clojure . t) ... etc, etc.)

So maybe that should be handled by org-layer?

@nanounanue
Copy link

I have the same problem:

My version of org-mode is

Org mode version 9.0 (9.0-elpa @ /home/nanounanue/.emacs.d/elpa/org-20161102/)

the Emacs version is

GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.8) of 2016-10-15

The relevant part of my personal emacs init file is:

(require 'ob-python)
(require 'ob-clojure)
(require 'ob-perl)
(require 'ob-dot)
(require 'ob-R)
(require 'ob-gnuplot)
(require 'ob-lisp)
(require 'ob-org)
(require 'ob-screen)
(require 'ob-calc)
(require 'ob-js)
(require 'ob-latex)
(require 'ob-plantuml)
(require 'ob-sh)
(require 'ob-ditaa)
(require 'ob-awk)
(require 'ob-octave)
(require 'ob-sed)
(require 'ob-sql)
(require 'ob-sqlite)

(org-babel-do-load-languages
 'org-babel-load-languages
 '( (perl . t)
    (dot . t)
    (R . t)
    (gnuplot . t)
    (clojure . t)
;;    (graphviz . t)
    (lisp . t)
;;    (stan . t)
    (org . t)
    (screen . t)
    (calc . t)
    (js . t)
    (latex . t)
    (plantuml . t)
    (ruby . t)
    (sh . t)
    (python . t)
    (emacs-lisp . t)
    (ditaa . t)
    (awk . t)
    (octave . t)
    (sed . t)
    (sql . t)
    (sqlite . t)
    ))

When I try to execute any block, even this from the documetation:

#+BEGIN_SRC emacs-lisp
(defun org-xor (a b)
"Exclusive or."
(if a (not b) b))
#+END_SRC

I got

Evaluation of this emacs-lisp code-blockis disabled.

The same happens with python, R, etc

Any ideas?

@madhat2r
Copy link
Contributor

madhat2r commented Nov 8, 2016

I have same exact issue as @nanounanue

@SimonAB
Copy link

SimonAB commented Nov 10, 2016

Same problem here using ipython code blocks, and not using Spacemacs... This bug seems to have been introduced to org mode after 2016-10-31.

@seldomworks
Copy link

Deleting *.elc files for org mode was the only thing that fixed the issue for me.
http://emacs.stackexchange.com/questions/28441/org-mode-9-unable-to-eval-code-blocks

@SimonAB
Copy link

SimonAB commented Nov 10, 2016

@seldomworks I can confirm this worked for me too. Thanks!

@madhat2r
Copy link
Contributor

This worked for me also, but in addition I had to recompile org-plus-contrib.

Thanks @seldomworks!

@cpaulik
Copy link
Contributor

cpaulik commented Nov 10, 2016

This might be related to the fact that a package update often installs org and org-plus-contrib in some order and the bytecode is then compiled with the wrong version. There might be a problem during the dependency resolution there.

@nickanderson
Copy link
Contributor

Purging ~/.emacs.d/elpa/org-20161102/*.elcworked for me as well.

@mathpunk
Copy link
Contributor

Purging ~/.emacs.d/elpa/org-20161102 did not work for me. Removed that entire dir, restarted emacs, same error.

(with-eval-after-load 'org
(setq-default dotspacemacs-configuration-layers
              '((org :variables org-enable-github-support t)))
(setq org-confirm-babel-evaluate nil
      org-src-fontify-natively t
      org-src-tab-acts-natively t)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((http       . t)
   (sh         . t)
   (js         . t)
   (emacs-lisp . t)
   (clojure    . t)
   (python     . t)
   (dot        . t)
   )))

I also tried putting in a (require 'ob-sh) to see if that had an effect, but no.

@nickanderson
Copy link
Contributor

Did you try just removing the elc files?

@mathpunk
Copy link
Contributor

@nickanderson That was the first thing that I tried. But I assumed that just trying to run the thing would get those files recompiled, and now I'm wondering if I need to take more action to get org reinstalled --- it is listed as a package in my .spacemacs, but the org directory has not reappeared in ~/.emacs.d/elpa.

@nickanderson
Copy link
Contributor

@mathpunk I had previously tried without success to delete the org directory in ~/.emacs.d/elpa. Restarting emacs would cause the package to he re-downloaded but my issue with SRC blocks persisted until I only removed the elc files and then restarted emacs.

@dubnde
Copy link
Contributor

dubnde commented Nov 19, 2016

I still see this issue as well

@Rand01ph
Copy link
Contributor

Rand01ph commented Nov 20, 2016

reinstall org layer maybe reslove this problem

@dubnde
Copy link
Contributor

dubnde commented Nov 20, 2016

@Rand01ph works if I delete the org-plus-contrib package in elpa folder so it reinstalls on next start up.

Note: It did not work when I wiped all org- packages or wiped the whole elpa folder. So it does seem the org-plus-contrib package must be the last package to install to mitigate the issue.

rm -rf elpa/org-plus-contrib-20161118/

@dubnde
Copy link
Contributor

dubnde commented Nov 20, 2016

blind me! It only works for a single session. If I restart emacs, stops working. Got to delete org-plus-contrib again.

@RockyRoad29
Copy link
Contributor

After trying unsuccessfully to debug the faulty #'org-babel-confirm-evaluate I decided to compare myself the "old" code, i.e.
/usr/share/emacs/25.1/lisp/org/ob-core.el.gz and the new : ~/.emacs.d/elpa/org-plus-contrib-20170210/ob*.el:
I found these interesting:
image

So the key point is that the definitions used to be inline functions, which are hard to debug and to get rid of.

\o/ :white_check_mark: After recompiling specifically elpa/org-plus-contrib-20170210/ob-core.el ,
Org Babel evaluation works !

I still wonder why recompile-elpa didn't do the job.

@aang7
Copy link

aang7 commented Feb 25, 2017

@RockyRoad29 Yiep! It works for me, thanks:)
PD: When I Update org-mode something breaks 🤕

@Atraii
Copy link

Atraii commented Mar 22, 2017

I would like to add that after deleting the *.elc files and recompiling, the python and emacs-lisp babel packages work for me, but C and C++ do not still.

I am getting No org-babel-execute function for C++!

Any solution for this?

@krux02
Copy link

krux02 commented May 3, 2017

I just wanted to comment. I tried several things here. I don't know what is the right thing to do and what is the wrong thing to do. I have this problem, and I thing this bug should get highest priority.

@aang7
Copy link

aang7 commented May 5, 2017

@ Krux02 Yep! It's so stressful that something breaks down when we update emacs packages, primordially org.

@krux02
Copy link

krux02 commented May 5, 2017

I just realized that this is the spacemacs issue tracker. I did not know that when I wrote that comment. I don't use spacemacs, and still I had this problem. I don't know if it helps to know that this problem is not just a spacemacs thing.

@agzam
Copy link
Contributor

agzam commented May 6, 2017

@krux02 then maybe you should switch to Spacemacs. Some users don't have that problem ;)

@nickanderson
Copy link
Contributor

I had this again after wiping my elpa subdirectory.
This time purging ~/.emacs.d/elpa/org-plus-contrib-* and restarting emacs seemed to do the trick as noted in #7641 (comment) I hadn't made it down to #7641 (comment) which is probably more specific.

@frapples
Copy link

I suggest that after upgrading org-mode, recompile the .elc file:

:spacemacs/recompile-elpa

@mathpunk
Copy link
Contributor

@frapples I am very happy that you've taught me this command exists; I've tried to force recompiling using deletions but this is better.

@localredhead
Copy link

@frapples that simple command did the trick for me. thanks!

@nickanderson
Copy link
Contributor

nickanderson commented Jun 19, 2017

+1 @frapples that worked for me as well. Previously I was purging files under .emacs.d/elpa/. :spacemacs/recompile-elpa is cleaner.

@duianto
Copy link
Collaborator

duianto commented Jun 20, 2017

@nickanderson The i and l in recompile got flipped to recomplie. You should probably fix that, so that someone else doesn't try the command and report that it doesn't work.

@dabro
Copy link

dabro commented Sep 25, 2017

None of these techniques work for me anymore. I've been through my spacemacs file multiple times looking for anything that could cause premature loading. The amount of time lost on this one bug is unbelievable.

@Hellseher
Copy link

Recompilation of Elpa did work for me as well, after update of packages. It's worth to include to main functionality of updates.

@tekacs
Copy link
Contributor

tekacs commented Oct 22, 2017

spacemacs/recompile-elpa after updating packages worked for me too.

@dabro
Copy link

dabro commented Oct 23, 2017

I've had a couple of successes since my last post deleting ob-core.elc and recompiling that one file.

@what-the-functor
Copy link
Contributor

Let's get to the bottom of this and close it. @dabro, if the issue arises again, can you post specifics?

Fortunately spacemacs/recompile-elpa is documented under Troubleshoot in DOCUMENTATION.org. Perhaps it's worthwhile to call spacemacs/recompile-elpa from configuration-layer/update-packages. Another idea is to check the emacs version at startup, if it has changed, call spacemacs/recompile-elpa.

Final point, this is yet another upstream change that is biting us. It's a common pattern. There has been a lot of discussion around pinning specific package versions. Such functionality, either via melpa-stable or our own package mirror, would diminish this class of bug from affecting Spacemacs.

@costrouc
Copy link

I ran into this exact error and I was not using spacemacs. Strangely doing the refresh talked about in the comments worked... but only for that session. in my case this stemmed from ob-sh.el trying to call a function that no longer exists org-babel-get-header https://emacs.stackexchange.com/questions/37692/how-to-fix-symbols-function-definition-is-void-org-babel-get-header . Setting (sh . t) -> (shell . t) in my .emacs fixed my issue.

I am by no means an expert at emacs and lisp so this could be unrelated.

@abondis
Copy link

abondis commented Dec 12, 2018

I don't know if that helps anybody, but I had this issue on develop. I removed ~/.emacs.d/elpa/25.2/develop/org-plus-contrib-* then restarted emacs and it works.

  • emacs 25.2.2, spacemacs develop (commit 5b2e969)
  • config :
(defun dotspacemacs/user-config ()
  (with-eval-after-load 'org
    (org-babel-do-load-languages
     'org-babel-load-languages
     '(
       (python . t)
       )
     )
  )
)

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests