When I do C-x C-f on ~/Desktop/ in macos Catalina, I get the following error.

Listing directory failed but 'access-file' worked

I can list the directory for just ~.

I'm new to Emacs and know little else. I've tried installing Emacs through Homebrew and using a binary from https://emacsformacosx.com

I've also searched for that error where some people said there's an issue with ls on mac, but I don't have any problem listing the contents of ~. Also, I didn't find any clear solution to that problem (I tried copy pasting answers to my init file but that didn't solve anything).

  • 1
    Welcome to emacs.SE! Can you ls ~/Desktop from a terminal?
    – JeanPierre
    Nov 21 '19 at 12:53
  • i can ls ~/Desktop, but first a popup appeared asking for permission
    – Nabi Yang
    Nov 22 '19 at 14:31
  • I found this: stackoverflow.com/questions/6192003/… And took the advice to take away write permission from my home folder: (from /Users): chmod go-w myusername
    – edj
    Mar 31 at 21:04

I found it. Apparently dired can't access icloud directories. My Desktop and Documents folders are sync'ed with icloud.


If anyone comes here curious as to how they can access Desktop, Documents, or Downloads, the answer is in the link above, for reference, but I'll put it here in case that link expires.

  1. In System Preferences -> Security & Privacy, select the Privacy tab.
  2. From the list on the left, select Full Disk Access.
  3. Click the padlock in the lower left of the window to unlock this setting, if necessary.
  4. Click the + button to add Emacs to the list, then add Emacs.

Now in Emacs, do the following for each of the three directories: Desktop, Documents, and Downloads.

  1. Press Cmd+O to open a file.
  2. Open any arbitrary file in the folder you want access to.

From now on, you'll be able to use C-x C-f to open ~/Desktop/, for example.

  • Can you get to them using a remote-file name? Can you get to it with Tramp, otherwise than using Dired? If so then try the same (remote-file name) with Dired.
    – Drew
    Nov 21 '19 at 15:16
  • 1
    Does it help if you customize the variable dired-use-ls-dired? Try setting to nil. Nov 22 '19 at 4:45
  • i haven't any clue what the remote file name is for my Desktop. i don't know what Tramp is either. i may be able to look into it later. i used M-x set-variable and typed in nil for dired-use-ls-dired but still have the same problem
    – Nabi Yang
    Nov 22 '19 at 14:38
  • 2
    Have you tried giving ruby full disk access? See emacs.stackexchange.com/questions/53026/… Nov 22 '19 at 21:14
  • 3
    Cmd+O actually refers to s-u bound to ns-open-file-using-panel, if you didn't tweak your bindings. For those tilting your head on that one, use M-x ns-open-file-using-panel instead.
    – Dean Seo
    Dec 12 '20 at 10:53

If you find the problem persists after granting Emacs full disk access: from here on the problem remains because Emacs on MacOS gets launched indirectly, from a Ruby script. Your Emacs binary has full disk access, but Ruby does not.

One way to get around this is to get the Ruby script out of the way, and replace it with a symlink to the correct binary for your platform. See


for an example.

  • 1
    I was having trouble with auto-complete in C-x C-f even after granting Emacs full-disk access. I liked this proposal about the Ruby script being the problem, but I didn't like having to make the symlink, and remember to do that every time I updated Emacs. I just granted Ruby full-disk access so it's more permanent, if a little more insecure. It's a little more complicated to get to /usr inside the standard Open dialog (to add Ruby), but press Command-Shift-. (that's a period at the end) to see the hidden files (think of it the period as a "dot" and then think of "dot files").
    – jimtut
    Dec 7 '20 at 16:23
  • At first I doubted, what was emacs doing with ruby scripts? But, then Homebrew packaging inserts those as an additional layer. Thanks. Sep 9 at 23:07

In my case, just allow Full Disk for ruby (/usr/bin/ruby) then it works like charm!

  • After following Nabi's instructions my problem persists. This answer fixed it for me!
    – spacegoing
    Nov 21 at 8:57

I followed Nabi and Vinh's solutions. dired worked but not all functions. For example, the sort is not working.

A quick search leads me here: https://github.com/d12frosted/homebrew-emacs-plus/issues/383#issuecomment-899157143

The problem is that macos's built-in ls does not support several flags dired+ use. What worked for me is following instructions here: https://stackoverflow.com/a/65112096/4062451

Notice that you might need to change the path insert-directory-program to where your brew is installed

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.