emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

org-babel-tangle throws an error when :tangle is not set


From: Rodrigo Morales
Subject: org-babel-tangle throws an error when :tangle is not set
Date: Sat, 27 Mar 2021 12:12:38 -0500
User-agent: mu4e 1.4.14; emacs 27.2

* System information

Emacs version: GNU Emacs 27.2

Org Mode version: Org mode version 9.4.4 (release_9.4.4 @ 
/usr/share/emacs/27.2/lisp/org/)

Operating system: Arch Linux

* The issue

In a freshly started Emacs (i.e. Emacs when it has been started through =emacs 
-Q=), the value of the variable =org-babel-default-header-args= is 

#+begin_src emacs-lisp
((:session . "none")
 (:results . "replace")
 (:exports . "code")
 (:cache . "no")
 (:noweb . "no")
 (:hlines . "no")
 (:tangle . "no")))
#+end_src

If we delete the cons cell whose car is =:tangle=. That is, if we evaluate the 
following expression,

#+name: value-for-variable
#+begin_src emacs-lisp :results silent
(setq org-babel-default-header-args
      '((:session . "none")
        (:results . "replace")
        (:exports . "code")
        (:cache . "no")
        (:noweb . "no")
        (:hlines . "no")))
#+end_src

then the function =org-babel-tangle= will throw the following error =Wrong type 
argument: stringp, nil= with the following backtrace

#+begin_example
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-directory(nil)
  org-babel-tangle-single-block(1)
  org-babel-tangle-collect-blocks(nil nil)
  org-babel-tangle(nil)
  funcall-interactively(org-babel-tangle nil)
  call-interactively(org-babel-tangle nil nil)
  command-execute(org-babel-tangle)
#+end_example

* Reproducing the issue

You can reproduce this issue by

1. Start Emacs by executing =emacs -Q=.
2. Save the content of this message to a file whose extension is =org=.
3. Evaluate the expression shown above from the code block named 
=value-for-variable=.
4. Execute =org-babel-tangle= be it interactively or through =eval-expression=.

* Additional information

This error can be avoided by explicitly having a =:tangle= header argument in 
each code block.

* Personal thoughts

I had to spend more than 90 minutes looking for the expression in my 
configuration that was causing this error. I think that either

+ showing a error message expressing that the =:tangle= header argument is not 
set for some code blocks when =org-babel-tangle= is executed.
+ explicitly stating in the documentation that the =:tangle= header argument is 
necessary for some functions to correctly work (e.g. =org-babel-tangle=)

could help other users to find this root cause so that they don't spend the 
time I spent looking for the issue.

-- 
Greetings,
Rodrigo Morales.

IRC: rdrg109 (freenode)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]