Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix Emacs permissions on macOS Catalina
;;; package --- Fix permissions for Emacs.app on macOS Catalina
;;; Author: Artem Loenko
;;; Mail-To: <artyom.loenko@mac.com>
;;; Commentary:
;;; Code:
(defconst _default-emacs-app-plist-path "/Applications/Emacs.app/Contents/Info.plist")
(defconst _temp-buffer-name "*fixing Emacs permissions*")
(defconst _temp-buffer (get-buffer-create _temp-buffer-name))
(with-current-buffer _temp-buffer (erase-buffer))
(defun add-description-if-needed (description_key description)
"DESCRIPTION_KEY - DESCRIPTION."
(defconst read-args (list "read" _default-emacs-app-plist-path description_key))
(if (equal 1 (with-temp-buffer (apply 'call-process "defaults" nil (current-buffer) nil read-args)))
(progn
(princ (format "Missing: %s. Adding...\n" description_key) _temp-buffer)
(defconst write-args (list "write" _default-emacs-app-plist-path description_key "-string" description))
(apply 'call-process "defaults" nil (current-buffer) nil write-args))
(princ (format "Existed: %s. Skipping.\n" description_key) _temp-buffer)))
(add-description-if-needed
"NSDesktopFolderUsageDescription"
"Emacs requires permission to access the Desktop folder.")
(add-description-if-needed
"NSDocumentsFolderUsageDescription"
"Emacs requires permission to access the Documents folder.")
(add-description-if-needed
"NSDownloadsFolderUsageDescription"
"Emacs requires permission to access the Downloads folder.")
(add-description-if-needed
"NSRemovableVolumesUsageDescription"
"Emacs requires permission to access files on Removable Volumes.")
(switch-to-buffer-other-window _temp-buffer)
;;; fix-emacs-permissions-catalina.el ends here
@juntakei
Copy link

juntakei commented Jul 6, 2020

I solved this by creating a Automator "Application": Utilities -> Run Shell Script -> exec /Applications/Emacs.app/Contents/MacOS/Emacs 2>&1

Thanks -- that works for me for the time being.

I got a similar issue with my Emacs which I compiled from GNU original source. When I called a command via Apple script (send a line message to Reminder), it failed even it is allowed on Security/Privacy Control panel. But calling emacs from Automator, it finally worked. Thank you!

@jcottrell
Copy link

jcottrell commented Apr 6, 2021

@waqarsaleem Many thanks. Your fix worked for me.

I fixed my problem by granting Full Disk Access to /usr/bin/ruby as instructed here.
https://emacs.stackexchange.com/a/53037/11143

I had previously given access to Emacs under /System/Volumes/Data/Applications/Emacs.app. My install was the brew install cask. My original error happened when trying to add a new project to Treemacs that was under my Downloads directory. It was probably also wrapped up in the fact that I first opened emacs from iTerm for that session and then Ctrl+c quit it. After that I re-installed emacs altogether and only found this solution at that point.

@waqarsaleem
Copy link

waqarsaleem commented Apr 17, 2021

@jcottrell I am glad. I know how important Emacs is to our workflows and understand the frustration and helplessness we feel when Emacs does not work!

@Kif11
Copy link

Kif11 commented Feb 5, 2022

As suggested by @waqarsaleem. I granted Full Disc access via System Preferences > Security > Full Disc Access for /bin /usr/bin/ruby and it worked!

@jccampagne
Copy link

jccampagne commented Mar 22, 2022

Same for me... (As suggested by @waqarsaleem, thanks).
Giving Full Disc access to /usr/bin/ruby in System Preferences > Security > Full Disc Access helped.
https://gist.github.com/dive/f64c645a9086afce8e5dd2590071dbf9?permalink_comment_id=3049341#gistcomment-3049341

@leonardoce
Copy link

leonardoce commented Mar 30, 2022

Same for me... (As suggested by @waqarsaleem, thanks). Giving Full Disc access to /usr/bin/ruby in System Preferences > Security > Full Disc Access helped. https://gist.github.com/dive/f64c645a9086afce8e5dd2590071dbf9?permalink_comment_id=3049341#gistcomment-3049341

Same for me too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment