I am experiencing a very unusual (concerning) error with my org-mode installation, and I am afraid that something might be broken. First, I have this setup in my .emacs file

;; Use my org-mode file as an init emacs file
 (expand-file-name "~/my_NOTES_file.org"

and when I try to load emacs there is an error in that org file. Starting with --debug-init reveals

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("emacs-lisp\\|elisp" nil nil)
  org-babel-tangle-collect-blocks("emacs-lisp\\|elisp" nil)
  org-babel-tangle(nil "/home/username/my_NOTES_file.el" "emacs-lisp\\|elisp")
  org-babel-tangle-file("/home/username/my_NOTES_file.org" "/home/username/my_NOTES_file.el" "emacs-lisp\\|elisp")
  eval-buffer(#<buffer  *load*> nil "/home/username/.emacs" nil t)  ; Reading at buffer position 1404
  load-with-code-conversion("/home/username/.emacs" "/home/username/.emacs" t t)
  load("~/.emacs" t t)
  #f(compiled-function () #<bytecode 0x1e0f4d>)()

so it seems that the functions following org-babel-tangle are receiving a nil for some reason. I have tried several things, including

  • a full reinstallation of emacs
  • tangled the emacs-lisp source blocks in the org file.
  • isolate the emacs-lisp code blocks in a separate org-mode file and use that one instead.

The last solution does work, but I'd rather have all my configuration in my main org file. This main file is rather large (31128 lines) and has source blocks from several other programming languages. However, these two factors shouldn't be an impediment right? Thank you in advance for any help.

  • 1
    The nil arguments are not the problem: they are all expected, except for the second argument in string-match which is supposed to be a string (and therefore cannot be nil). Does M-x org-lint point out any problems?
    – NickD
    Commented Jan 26, 2021 at 1:51
  • THANK YOU! M-x org-lint is EXACTLY what I needed to check for errors in such big org file: very handy tool. At the end, the problem was this line 19304 low Possible incomplete block "#+begin_src shell, i.e., a shell source block which was not properly constructed--the +END_SRC line had been backspaced to the last line of the code (no idea how/why). Happy to accept this answer if you post it.
    – Ajned
    Commented Jan 26, 2021 at 8:30
  • Oh, good! org-lint is not as well known as it should be, so this is a good opportunity to publicize it :-)
    – NickD
    Commented Jan 26, 2021 at 13:34

1 Answer 1


A good tool for finding errors in Org mode files is org-lint: just visit the file, say M-x org-lint and fix any problems it finds. There is no guarantee that it will find everything, so you might still end up having to debug your file using other methods, but it is a quick and easy first step that just might solve the problem, as it did here.

The doc string of the function is a bit too concise:

Check current Org buffer for syntax mistakes.

By default, run all checkers. With a ‘C-u’ prefix ARG, select one category of checkers only. With a ‘C-u C-u’ prefix, run one precise checker by its name.

ARG can also be a list of checker names, as symbols, to run.

leaving one with questions about what checkers are available. For that, you will have to consult the Commentary section in org-lint.el. For the record, here's the bare list:

  • duplicate CUSTOM_ID properties
  • duplicate NAME values
  • duplicate targets
  • duplicate footnote definitions
  • orphaned affiliated keywords
  • obsolete affiliated keywords
  • missing language in source blocks
  • missing back-end in export blocks
  • invalid Babel call blocks
  • NAME values with a colon
  • deprecated export block syntax
  • deprecated Babel header properties
  • wrong header arguments in source blocks
  • misuse of CATEGORY keyword
  • "coderef" links with unknown destination
  • "custom-id" links with unknown destination
  • "fuzzy" links with unknown destination
  • "id" links with unknown destination
  • links to non-existent local files
  • SETUPFILE keywords with non-existent file parameter
  • INCLUDE keywords with wrong link parameter
  • obsolete markup in INCLUDE keyword
  • unknown items in OPTIONS keyword
  • spurious macro arguments or invalid macro templates
  • special properties in properties drawer
  • obsolete syntax for PROPERTIES drawers
  • Invalid EFFORT property value
  • missing definition for footnote references
  • missing reference for footnote definitions
  • non-footnote definitions in footnote section
  • probable invalid keywords
  • invalid blocks
  • misplaced planning info line
  • incomplete drawers
  • indented diary-sexps
  • obsolete QUOTE section
  • obsolete "file+application" link
  • spurious colons in tags

Consult the doc string of the constant org-lint--checkers (do C-h v org-lint--checkers) for the names that you can use in the org-lint invocation, if you want to run a particular checker, although in that case, it's easier to do C-u M-x org-lint TAB or C-u C-u M-x org-lint TAB and use completion (category completion in the first case, checker completion in the second).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.