Very helpful answer from gavenkoa. I'm having this problem on Emacs 24.1, Windows 2003.
Unfortunately, overriding server-ensure-safe-dir to become a noop, as suggested in your first snippet, didn't work for me in all situations. Specifically, it did not work when applied before (server-start) had executed at least once, because the initial execution would also create the directory, if it doesn't exist. With the noop version, the directory would not be created at all.
The workaround that worked for me in the sense that it eliminated the error message, while still creating the directory properly, was the following code, put before (server-start) in my Emacs initialization file. It puts an advice around server-ensure-safe-dir to ignore any errors raised from there. Doesn't solve the root cause of the problem, but good enough for me.
(defadvice server-ensure-safe-dir (around
my-around-server-ensure-safe-dir
activate)
"Ignores any errors raised from server-ensure-safe-dir"
(ignore-errors ad-do-it))
Added in 2025, for new version of Emacs like 30.1, it is recommended to use advice-add
, see example below,
(defun my--safe-server-ensure-safe-dir (orig-fun &rest args)
"Ignore any error when checking server socket directory."
(ignore-errors (apply orig-fun args)))
(advice-add 'server-ensure-safe-dir :around #'my--safe-server-ensure-safe-dir)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4