'Emacs Dired not working - Searching for program: no such file or directory, ls

When I open emacs, and type C-x C-f RET, the minibuffer says

Searching for program: no such file or directory, ls

This also happens when I press return after having typed any directory name. Dired doesn't work when i use C-x d either. Finding files works fine.

I'm using mac os x 10.11 and GNU Emacs 24.5.1. Is there something that could have been put in .emacs to cause this? Also, it seemed to be working fine until I restarted my computer.



Solution 1:[1]

You can use which ls in bash to find where ls is located, say it is in /bin/ls whose parent directory is /bin. Then you need to add the parent directory /bin to both PATH and exec-path with following code.

(setenv "PATH" (concat (getenv "PATH") ":/bin"))
(setq exec-path (append exec-path '("/bin")))

Note that the parent directory /bin should be both in PATH and exec-path, to check if this config is setup:

  • M-x get-env PATH RET
  • M-x describe-variable exec-path RET

Sometime /bin may not appended to exec-path correctly, you can use Emacs's own customizations workflow

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1