Ever since upgrading to emacs 24.x
I've been seeing this error whenever I open a directory. The entire error is:
ls does not support --dired; see `dired-use-ls-dired' for more details.
Looking at the variable, one finds:
dired-use-ls-dired is a variable defined in `dired.el'.
Its value is nil
Original value was unspecified
Documentation:
Non-nil means Dired should pass the "--dired" option to "ls".
The special value of `unspecified' means to check explicitly, and
save the result in this variable. This is performed the first
time `dired-insert-directory' is called.
Note that if you set this option to nil, either through choice or
because your "ls" program does not support "--dired", Dired
will fail to parse some "unusual" file names, e.g. those with leading
spaces. You might want to install ls from GNU Coreutils, which does
support this option. Alternatively, you might want to use Emacs's
own emulation of "ls", by using:
(setq ls-lisp-use-insert-directory-program nil)
(require 'ls-lisp)
This is used by default on MS Windows, which does not have an "ls" program.
Note that `ls-lisp' does not support as many options as GNU ls, though.
For more details, see Info node `(emacs)ls in Lisp'.
You can customize this variable.
I'm running on FreeBSD; so the default ls
is not GNU'ish and doesn't offer the --dired
option. I don't really feel like going to the trouble to install GNU coreutilities on all of my servers.
Anyone have any experience with the lisp ls
alternative mentioned above?
Presumably dired.el
is setting dired-use-ls-dired
to something non-nil when loaded and I'm constantly clobbering it the first time I view a directory? And setting dired-use-ls-dired
to nil in my .emacs
would quiet the message?
Does anyone have the opinion that not getting dired to work might represent a security issue? i.e. would filenames composed of whitespace remain invisible?
Maybe I should test some of the above...
on macOS, ls
doesn't support the --dired
option while on Linux it is supported.
(when (string= system-type "darwin")
(setq dired-use-ls-dired nil))
In this case you can also try to use gnu-ls, you can install this utilities takea look here how-to-replace-mac-os-x-utilities-with-gnu-core-utilities
In my case I maintain both and the gnu core utilities are prefixed by "g".
If you use gls, the --dired argument is enabled
man gls
NAME ls - list directory contents
SYNOPSIS ls [OPTION]... [FILE]...
DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too. .... -d, --directory list directories themselves, not their contents ....
which gls
/usr/local/bin/gls
Then we have all too configure emacs:
(when (string= system-type "darwin")
(setq dired-use-ls-dired t
insert-directory-program "/usr/local/bin/gls"
dired-listing-switches "-aBhl --group-directories-first"))
Then you can use this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With