Dired used to run fine on my machine (Ubuntu 14.04). But for a while now, i keep running into the error (wrong-type-argument stringp nil). This does not only happen with dired but also with other commands taking an argument (from the minibar).

From searching the web it seems that the error message comes up in situations with some misconfiguration, but I haven't been able to figure it out just yet.

Full error message:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
call-process(nil nil nil nil "--dired")
dired-insert-directory("/home/hb/test/" "-al" nil nil t)
dired-internal-noselect("~/test/" nil)
dired-noselect("/home/hb/test/ nil)
ido-file-internal(dired dired nil "Dired: " dir)
call-interactively(ido-dired nil nil)
  • 3
    What's the value of insert-directory-program?
    – npostavs
    Commented Aug 12, 2016 at 13:23
  • What @npostavs said. Also, does the same thing happen if you don't use Ido and just do M-x dired? What are the values of variables ls-lisp-use-insert-directory-program and dired-use-ls-dired? (The backtrace and the fact that the 3rd arg to call-process is nil suggests that this is happening directly in dired-insert-directory and not in insert-directory.) And what happens if you start Emacs using emacs -Q (no init file) - same problem?
    – Drew
    Commented Aug 12, 2016 at 15:31
  • @npostavs 'insert-directory-program is a variable defined in `files.el'. Its value is nil' @Drew dired works without the init file. 'dired-use-ls-dired' is a variable defined in dired.el. 'Its value is unspecified'. 'ls-lisp-use-insert-directory-program' doesn't seem to exist?
    – stats-hb
    Commented Aug 14, 2016 at 23:12
  • 1
    Something in your init file must be setting insert-directory-program to nil, the default value is "ls".
    – npostavs
    Commented Aug 15, 2016 at 3:00
  • well, I built upon the start-kit for social sciences and as this tailored to OSX the inser-directory-program was set to gls (GNU ls) which I didn't have on my machine. Commenting the part out solved the problem. Do you care to post it as an answer so that I can accept? Ty!! :)
    – stats-hb
    Commented Aug 15, 2016 at 10:42

1 Answer 1


The backtrace you give in the question actually has all the information you need to debug this so while the answer is in the comments I'll go through the logic.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
call-process(nil nil nil nil "--dired")

So an argument here has failed the stringp predicate check. This first place to look is at C-h f call-process:

call-process is a built-in function in ‘C source code’.

(call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS)

Call PROGRAM synchronously in separate process.

Well that's a bit of a pain, it is in the C code. If you have a copy of the code checked out you could have looked and found the following in src/callproc.c:

if (nargs >= 2 && ! NILP (args[1]))
    infile = Fexpand_file_name (args[1], BVAR (current_buffer, directory));
    CHECK_STRING (infile);

But as most people don't have the C code on their systems we'll look higher up the stack. From the help text though it seems pretty likely calling call-process with nil for its only mandatory argument isn't going to end well. So up the stack:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
call-process(nil nil nil nil "--dired")
dired-insert-directory("/home/hb/test/" "-al" nil nil t)

So we visit C-h f dired-insert-directory and follow the link to dired.el to look at the code. M-x narrow-to-defun and we can search just in this function for the call-process invocation:

(if (and
 ;; Don't try to invoke `ls' if we are on DOS/Windows where
 ;; ls-lisp emulation is used, except if they want to use `ls'
 ;; as indicated by `ls-lisp-use-insert-directory-program'.
 (not (and (featurep 'ls-lisp)
       (null ls-lisp-use-insert-directory-program)))
 (or (if (eq dired-use-ls-dired 'unspecified)
     ;; Check whether "ls --dired" gives exit code 0, and
     ;; save the answer in `dired-use-ls-dired'.
     (or (setq dired-use-ls-dired
           (eq 0 (call-process insert-directory-program
                     nil nil nil "--dired")))
           (message "ls does not support --dired; see `dired-use-ls-dired' for more details.")
     (file-remote-p dir)))
(setq switches (concat "--dired " switches)))

And we see the invocation:

(call-process insert-directory-program nil nil nil "--dired")

A quick C-h v insert-directory-program:

insert-directory-program is a variable defined in ‘files.el’.
Its value is "ls"

  This variable may be risky if used as a file-local variable.

Absolute or relative name of the ‘ls’ program used by ‘insert-directory’.

And if we follow the link to the definition:

(defvar insert-directory-program (purecopy "ls")
  "Absolute or relative name of the `ls' program used by `insert-directory'.")

So we can see it defaults to "ls", ergo if it is not set something has messed with the setting. You can verify this by running emacs -Q to confirm the default setup works.

  • this is awesome!
    – stats-hb
    Commented Aug 16, 2016 at 13:04
  • @stats-hb: given how much of Emacs' internals are directly accessible to the user I tend to prefer the "teach a man to fish" approach. Having said that it took me a long time to get used to the syntax - but once over that hurdle....
    – stsquad
    Commented Aug 16, 2016 at 14:34

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.