I'm following the tutorial here to implement my init.el file in org mode. I therefore cleaned out my init.el file and added this only:

(require 'org)
 (expand-file-name "emacs-init.org"

When I do I get the following error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  mapc(org-babel-load-file ("/home/tom/.emacs.d/emacs-init.org"))
  eval-buffer(#<buffer  *load*> nil "/home/tom/.emacs.d/init.el" nil t)  ; Reading at buffer position 1065
  load-with-code-conversion("/home/tom/.emacs.d/init.el" "/home/tom/.emacs.d/init.el" t t)
  load("/home/tom/.emacs.d/init" t t)

It seems that the expand-file-name function is working, but for some reason nil is being passed to the load-file function. Is that a proper reading of this stack trace? And if so, then why is that happening?


Load the source file that defines org-babel-load-file (*.el, not *.elc). Then M-x debug-on-entry org-babel-load-file. Use d to step through the execution, to see why, given the argument "/home/tom/.emacs.d/emacs-init.org", it ends up trying to load nil and not a file name. You can use c to skip through any steps you are not interested in digging into.

See the Elisp manual, node Function Debugging (and its parent node, Debugger).

  • This is really fantastic advice and I used this debugging process to solve the problem. Thanks again Drew! I didn't accept it as the answer though because there's a much more direct route to solving this issue. – Tom Purl Jan 12 '17 at 14:09

Ok, after using Drew's debugging steps I learned that org-babel-load-file basically does the following:

  1. Load your emacs-init.org file in org-mode.
  2. Strip out all of the emacs-lisp code blocks that contain your emacs config.
  3. Put those emacs-lisp code blocks into a file called emacs-init.el.
  4. It then executes the code in that file.

My issue was that my emacs-init.org file didn't yet contain any emacs-lisp code blocks so it couldn't create the emacs-init.el file, which is why nil is being passed to load-file.

So here's what I'm doing instead that is working much better.

  1. I added the code snippet in my question to the top of my existing init.el file.
  2. I then created an emacs-init.org file in the .emacs.d dir.
  3. I then moved a couple lines of config from init.el to emacs-init.org.
  4. I then start a second emacs process to test everything.

My plan is to move everything in chunks like this.


You must tell your "emacs-init.org" which language is it.


Example for emacs-lisp

#+BEGIN_SRC emacs-lisp
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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