Apple - Restore Access to File System for Emacs on MacOS Catalina
I solved the problem by granting Full Disk Access to /usr/bin/ruby
as suggested here. Quoting from the reply,
Emacs.app actually launches using a ruby script. As a result, MacOS Catalina uses the permissions set for ruby, not the permissions for Emacs.app.
Grant access as follows.
- Go to "System Preferences -> Security & Privacy -> Privacy"
- Select Full Disk Access from the left menu. It is about half way down in the menu. A list of apps will appear in the main region of the window.
- Click the lock on the lower left and authenticate in order to allow making changes.
- Click the + button under the list of software and select
/usr/bin/ruby
./usr
is usually a hidden folder and may not appear by default. If so, press shift+cmd+. (the last one is a dot) at the root directory to make it appear.
Emacs.app should now be able to access the file system without any hindrance!
This is caused by the Privacy features introduced with macOS Mojava and expanded with macOS Catalina. Essentially apps are sandboxed and not allowed to access the full disk, unless you give them that permission.
You can give an application access to the full disk like this:
- Open System Preferences
- Click Privacy & Security
- Choose the Privacy tab
- Select Full Disk Access in the lift on the left
- Click the lock in the bottom left corner to unlock
- Drag the application into the list on the right
The next time you launch the application, it will have access to the full disk.
The standard emacs supplied with the system is run through Terminal.app. If you're using emacs like this (with the system supplied or for example an installation from HomeBrew or MacPorts), you need to drag Terminal.app on to the list to give access.
If you're using a third party GUI-based Emacs, you'll need to drag the .app for that program on to the list.
Note that some Emacs "distributions" package together a number of Emacs binaries for various macOS versions in a single folder, and dynamically at runtime chooses the right one for your system. This means that the icon you click to start the program is really a "placeholder" that is not Emacs itself, but rather just starts up Emacs. This "placeholder" often takes the form of a Ruby script. If this is the case, you'll need to drag the Ruby program on to the list.
Ruby comes with macOS by default. You can find the program by opening Finder, and then from the "Go" menu choose "Go to Folder". Enter "/usr/bin" and you'll get that folder opened in Finder. In the folder, you'll find the ruby program that you can drag on to the Full Disk Access list.