Emacs - Error on call (server start)

I am currently using GNU Emacs 23.0.93.1 on Windows Vista Service Pack 1 (SP1). In my .emacs file, I make a call (server-start) and throw a message error. The ~ / .emacs.d / server directory is not secure. Has anyone seen this and knew about a fix or workaround? ... except that the server is down;)

Here is the stack trace:

 Debugger entered--Lisp error: (error "The directory ~/.emacs.d/server is unsafe") signal(error ("The directory ~/.emacs.d/server is unsafe")) error("The directory %s is unsafe" "~/.emacs.d/server") server-ensure-safe-dir("~\\.emacs.d\\server\\") server-start(nil) call-interactively(server-start t nil) execute-extended-command(nil) call-interactively(execute-extended-command nil nil) 
+74
windows emacs elisp dot-emacs
May 20 '09 at 1:35
source share
11 answers

I found this solution on EmacsWiki:

"The problem is that you have rights to the ~ / .emacs.d / server directory when you also have the Administrators rights in your account. Create the ~ / .emacs.d / server directory and set the owner of this directory to your login name, and the problem disappeared.As I have a "Dutch" version of Windows 7, I don’t know the English terms, but this is the procedure:

Click the R-mouse on ~ / .emacs.d / server and select "Properties" (last item on the menu). From the property, select the Security tab, and then click the Advanced button. Then select the Owner tab and change the owner from Administrators (<your-pc-name>\Administrators) to <your-login-name> (<your-pc-name>\<your-login-name> . Now the server code will accept this directory as safe because you own it.

Hope this helps all of you guys solved the problem anyway.

WKR Reutefleut "

It definitely works on Vista with Emacs 23.2.1.

+137
May 31 '10 at 2:37
source share

I like it when I use larsreed, but compile the code ready for use:

 (require 'server)
 (when (and (> = emacs-major-version 23)
            (equal window-system 'w32))
   (defun server-ensure-safe-dir (dir) "Noop" t));  Suppress error "directory
                                                  ;  ~ / .emacs.d / server is unsafe "
                                                  ;  on windows.
 (server-start)

I will talk about this problem in my blog article http://brain-break.blogspot.com/2009/08/when-moving-from-gnu-emacs-22.html

Also note that bug # 4197 about server-security-dir was fixed in 2009-09-19, so this workaround is not required in incoming Emacs 23.2.

In the recently released Emacs 23.2, I have this warning:

Warning (server): using ~/.emacs.d/server to store Emacs server authentication files. Directories on FAT32 file systems are NOT protected against unauthorized access. See the variable server-auth-dir more details.

To fix this, how to say a warning, you can point server-auth-dir to the NTFS partition ( %APPDATA% usually found in Windows %SYSTEMDRIVE% , and the user usually formats the system drive as an NTFS partition):

 (require 'server)
 (when (and (eq window-system 'w32) (file-exists-p (getenv "APPDATA")))
   (setq server-auth-dir (concat (getenv "APPDATA") "/.emacs.d/server"))
   (make-directory server-auth-dir))
 (server-start)
+26
Oct 14 '09 at 14:25
source share

This is a known Emacs error for Windows. The workaround is to comment out this line in server-provide-safe-dir in server.el, you will want to recompile the bytes after the change:

 ;; FIXME: Busted on Windows. ;; (eql (nth 2 attrs) (user-uid)) 
+13
May 20 '09 at 1:56
source share

To avoid hacking in the lisp directory, you can simply add the following to your .emacs:

(require 'server) (and (>= emacs-major-version 23) (defun server-ensure-safe-dir (dir) "Noop" t))

+9
Aug 21 '09 at 18:32
source share

In addition, you do not want the server to start in batch mode. So in my .emacs I use

 (defconst --batch-mode (or noninteractive (member "--batch-mode" command-line-args)) "True when running in batch-mode (--batch-mode command-line switch set).") 

and then

 (unless --batch-mode (require 'server) (when (and (= emacs-major-version 23) (= emacs-minor-version 1) (equal window-system 'w32)) ;; Suppress error "directory ~/.emacs.d/server is unsafe" on Windows. (defun server-ensure-safe-dir (dir) "Noop" t)) (server-start)) 

Nevertheless, the server function is capricious: server-start issues when the directory% HOME% /. emacs.d / server does not exist. Subsequently, Emacs will not start again! The obvious solution is to create the missing directory and try again; I found a solution somewhere on the net, but I really can’t remember where. The following code has been running on my several Windows machines for many years:

 (unless --batch-mode (require 'server) (when (and (= emacs-major-version 23) (= emacs-minor-version 1) (equal window-system 'w32)) ;; Suppress error "directory ~/.emacs.d/server is unsafe" on Windows. (defun server-ensure-safe-dir (dir) "Noop" t)) (condition-case nil (server-start) (error (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir))) (when (and server-use-tcp (not (file-accessible-directory-p server-dir))) (display-warning 'server (format "Creating %S" server-dir) :warning) (make-directory server-dir t) (server-start)))) ) ) 

This code also works when starting Emacs from a stick.

Hope this helps.

+6
Aug 10 '11 at 11:20
source share

Not working for me on Windows 7.

Instead, I read the comments in the server-provide-safe-dir file and continued to accept ownership of the% APPDATA% forlder and subfolders. They belonged to local administrators, not to me.

That helped!

+5
Mar 29 '10 at 6:39
source share

A very useful answer from the little thing. I have a problem with Emacs 24.1, Windows 2003.

Unfortunately, overriding secure-dir-server-security to become noop, as suggested in your first snippet, does not work for me in all situations. In particular, this did not work if it was applied before (starting the server) at least once, since the initial execution also created the directory , if it does not exist, with the noop version the directory will not be created at all.

The workaround that worked for me in the sense that it deleted the error message when the directory was created correctly was the following code that was put earlier (server start) in my Emacs initialization file. He sets up server-server security advice to ignore any errors that occur. Does not solve the root cause of the problem, but 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)) 
+3
Jun 12 '13 at 15:21
source share

In case this strikes people from time to time, my workstation simply went through a “domain migration”, which added a different permission for each file in the field, after which I started to get this error. After I added the expression to the dummy "server-provide-safe-dir", it stopped.

(If you are interested, the transition will be carried out in 2-3 steps. The first one will add permission to me in the target domain, then I will go to the target domain, then they can (I’m not necessarily talking about this) remove the permission for the old domain. This is a big company and many users, so they do it separately.)

+1
Aug 09 '10 at 23:15
source share

The last time I tried, the Take Property shell extension completed the task

+1
Jul 03 '11 at 10:17
source share

Below my step works: 1. Run the code below as a .reg file. The Emacs win version will handle any registry value as Env Var.

 [HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs] "HOME"="C:/<your_emacs_home>" "EMACS_SERVER_FILE"="C:/<your_emacs_home>/server/main_server" "ALTERNATE_EDITOR"="C:/<your_emacs_loc>/bin/runemacs.exe" 
  1. Add the code below to your .emacs / init.el. The key here should be "server-auth-dir".
 (require 'server) (setq server-auth-dir "~/server") ;;Server file location (setq server-name "main_server") ;;Server mutex file name (server-start) 

Using the steps above, server mode works for me correctly and perfectly.

+1
Jan 02 '15 at 16:51
source share

If this is a server folder permissions issue identified by RealityMonster, you can run it on the Windows command line to fix it:

 takeown /f %USERPROFILE%\.emacs.d\server /r /dy 
0
Sep 01 '17 at 14:24
source share



All Articles