I am trying to write emacs init using Org-mode By using org-babel-load-file function in init.el. My init.el file is

(require 'package)
(add-to-list 'package-archives    
         '("melpa" . "https://melpa.org/packages/")
         '("marmalade" . "http://marmalade-repo.org/packages/")
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(org-babel-load-file (expand-file-name "settings.org"

But on using so I am getting the following error message

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  eval((org-babel-load-file (expand-file-name "settings.org" user-emacs-directory)) nil)
  call-interactively(eval-last-sexp nil nil)

I would appreciate any input on the subject.

  • Do you include the elisp code in src blocks with the :tangle yes header argument?
    – JeanPierre
    Nov 10, 2016 at 10:21
  • I'm really new to Emacs. I think I haven't included that. Nov 10, 2016 at 11:26

2 Answers 2


As hinted by org-babel-load-file docstring (C-h f):

Load Emacs Lisp source code blocks in the Org-mode FILE. This function exports the source code using org-babel-tangle and then loads the resulting file using load-file.

Your stack trace suggests there's a problem with the tangling (load-file is provided a nil arg as the file name).

Src blocks are tangled according to their header argument:

Header arguments

:tangle no The default. The code block is not included in the tangled output.

:tangle yes Include the code block in the tangled output. The output file name is the name of the org file with the extension ‘.org’ replaced by the extension for the block language.

:tangle filename Include the code block in the tangled output to file ‘filename’.

So you could add a :tangle yes header arg to the source blocks in file settings.org.


I've had the same issue with my org settings file. The reason behind was that I used #+BEGIN_SRC elisp instead of #+BEGIN_SRC emacs-lisp. Therefore, the function org-babel-load-file considered that there was no elisp code to execute and return nil.

I wasn't aware of that solution early because the code highlight was activated. According to this answer, elisp is an alias of emacs-lisp. You can check if you have the function org-babel-execute:elisp defined. In my case, I had only org-babel-execute:emacs-lisp, that's why it didn't work.

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.