Dear Experts,

I *love* org-babel. In trying to switch a bunch of things to using it, I have run into the problem that if I get the syntax slightly wrong, either nothing happens (no output) or I just get something like "ERROR". Is there a way to understand what is causing the error? So far, I have resorted to creating a checklist of common mistakes which I run through whenever something doesn't work. I think many of these look like things which could in theory be detected and warned or complained about. Any suggestions on debugging would be much appreciated.

Below is a list of some common mistakes.

** common mistakes

*** forgetting colon on srcname

If you do the following (note the missing colon on srcname)

#+srcname Cube(x=3)
#+begin_src python :results value :export code
return x*x*x
#+end_src

then things won't work (e.g., you may get an error about "global name
'x' is not defined" which is pretty confusing).

Instead, make sure you have the colons and do

#+srcname: Cube(x=3)
#+begin_src python :results value :export both
return x*x*x
#+end_src

which gives

#+results: Cube
: 27

*** forgetting = in chained sbe call

Make sure you include the = sign in a chained sbe call like the
following:

| 512 |
#+TBLFM: @1$1='(sbe "Cube" (x "Cube(x=2)"))

If you forget the = as in
| 19683 |
#+TBLFM: @1$1='(sbe "Cube" (x "Cube(x 1)"))

or if you forget a quote as in
| #ERROR |
#+TBLFM: @1$1='(sbe "Cube" (x "Cube(x=2)))
it won't work.

*** getting confused on sbe call

It's common to forget that the sbe syntax uses pairs *without* the
equal sign. Consequently, something like
| #ERROR |
#+TBLFM: @1$1='(sbe "Cube" (x=2))

won't work but something like

| 8 |
#+TBLFM: @1$1='(sbe "Cube" (x 2))

will do what you want.