Skip to content

Problems with Dired configuration on macOS #80

@ricky9w

Description

@ricky9w

ls on macOS does not support long-format options(such as --dired), as a result, the Dired configuration causes an error message like this:

Listing directory failed but 'access files' worked

Delete --group-directories-first argument can help get rid of this error, but a GNU-based ls which is exposed as gls by the coreutils formula can solve this problem. Here's my solution to this:

  1. install homebrew
  2. run brew install coreutils to install gls
  3. add some judgements to the Dired configuration:
(use-package dired
  :ensure nil
  :commands (dired dired-jump)
  :bind (("C-x C-j" . dired-jump))
  :config
  (when (string= system-type "darwin")
  (let ((gls (executable-find "gls")))
  (when gls
  (setq dired-use-ls-dired t
    insert-directory-program gls
    dired-listing-switches "-aBhl --group-directories-first")))))

Note that GUI applications and applications launched via shell see different environment variables on macOS, so executable -find function may not be able to find gls if you start Emacs by clicking the app icon or from spotlight. Thankfully a package called exec-path-from-shell can help. Here is the GitHub homepage for this package:
https://github.com/purcell/exec-path-from-shell
More info:
https://stackoverflow.com/questions/8606954/path-and-exec-path-set-but-emacs-does-not-find-executable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions