emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
To: emacs-orgmode@gnu.org
Subject: org-babel-tangle throws an error when :tangle is not set
Date: Sat, 27 Mar 2021 12:12:38 -0500	[thread overview]
Message-ID: <877dlsldvd.fsf@gmail.com> (raw)


* 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	other threads:[~2021-03-27 17:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877dlsldvd.fsf@gmail.com \
    --to=moralesrodrigo1100@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).