Emacs - 调用时出错(服务器启动)

发布于 2024-07-19 18:46:16 字数 635 浏览 10 评论 0原文

我目前在 Windows Vista SP1 中使用 GNU Emacs 23.0.93.1。 在我的 .emacs 文件中,我调用了 (server-start) ,这导致出现错误并显示消息 目录 ~/.emacs.d/server 不安全 。 有没有人见过这个并知道修复或解决方法? ...除了关闭服务器之外;)

这是堆栈跟踪:

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)

I am currently using GNU Emacs 23.0.93.1 in Windows Vista SP1. In my .emacs file I make a call to (server-start) and that is causing an error with the message The directory ~/.emacs.d/server is unsafe. Has anyone seen this and know a fix or workaround? ... other than leaving server turned off ;)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

旧街凉风 2024-07-26 18:46:16

我在 EmacsWiki 上找到了这个解决方案

当您的帐户还拥有“管理员”权限时,问题在于目录 ~/.emacs.d/server 的所有权。 创建目录 ~/.emacs.d/server 并将该目录的所有者设置为您的登录名,问题就消失了。 由于我有“荷兰语”版本的 Windows 7,我不太清楚英文术语,但步骤如下:

在 ~/.emacs.d/server 上单击 R 鼠标并选择“属性”(菜单中的最后一项)。 从“属性”中选择“安全”选项卡,然后选择“高级”按钮。 然后选择“所有者”选项卡并将所有者从 Administrators (\Administrators) 更改为 \。现在服务器代码将接受此目录为安全目录,因为您是所有者。

希望这对大家有帮助,无论如何它解决了我的问题。

WKR 罗伊特弗勒特

它绝对可以在 Vista 和 Emacs 23.2.1 上运行。

I found this solution on the EmacsWiki:

The problem is the ownership of the directory ~/.emacs.d/server when you also have “Administrators” rights on your account. Create the directory ~/.emacs.d/server and set the owner of this directory to your login name and the problem is gone. As I have a “Dutch” version of Windows 7 I don’t know the English terms exactly but here’s the procedure:

Click R-mouse on ~/.emacs.d/server and select “Properties” (last item in menu). From Properties select the Tab “Security” and then select the button “Advanced”. Then select the Tab “Owner” and change the owner from Administrators (<your-pc-name>\Administrators) into <your-login-name> (<your-pc-name>\<your-login-name>. Now the server code will accept this directory as secure because you are the owner.

Hope this helps for all you guys, it solved the problem for me anyway.

W.K.R. Reutefleut

It definitely works on Vista, with Emacs 23.2.1.

浅笑依然 2024-07-26 18:46:16

我喜欢回答 larsreed,但完整的代码可供使用:

(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)

我在我的博客文章中讨论了这个问题 http://brain-break.blogspot.com/2009/08/when-moving-from-gnu-emacs-22.html

另请注意,在2009-09-19 修复了有关 server-ensure-safe-dir 的错误 #4197,因此在即将推出的 Emacs 23.2 中不需要此解决方法。

在最近发布的 Emacs 23.2 下,我有这样的警告:

警告(服务器):使用 ~/.emacs.d/server 来存储 Emacs 服务器身份验证文件。
FAT32 文件系统上的目录不能防止篡改。
有关详细信息,请参阅变量 server-auth-dir

要修复此警告,您可以将 server-auth-dir 指向 NTFS 分区(%APPDATA% 通常位于 Windows %SYSTEMDRIVE% 并且用户通常将系统驱动器格式化为 NTFS 分区):

(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)

I enjoy to anwer of larsreed, but complite code ready to 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 discass this issue in my blog article http://brain-break.blogspot.com/2009/08/when-moving-from-gnu-emacs-22.html

Also note that in 2009-09-19 fixed bug #4197 about server-ensure-safe-dir so in incoming Emacs 23.2 this workaround is not needed.

Under recently released Emacs 23.2 I have such warning:

Warning (server): Using ~/.emacs.d/server to store Emacs-server authentication files.
Directories on FAT32 filesystems are NOT secure against tampering.
See variable server-auth-dir for details.

To fix this as say warning you can point server-auth-dir to NTFS partition (%APPDATA% usually located Windows %SYSTEMDRIVE% and user usually format system drive as 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)
愿得七秒忆 2024-07-26 18:46:16

这是 Windows 上已知的 Emacs 错误。 解决方法是注释掉这一行
server.el 中的 server-ensure-safe-dir 更改后您需要字节重新编译:

;; FIXME: Busted on Windows. 
;; (eql (nth 2 attrs) (user-uid)) 

This is a known Emacs bug on Windows. A workaround is to comment out this line in
server-ensure-safe-dir in server.el the you'll want to byte recompile after the change:

;; FIXME: Busted on Windows. 
;; (eql (nth 2 attrs) (user-uid)) 
少跟Wǒ拽 2024-07-26 18:46:16

为了避免在 lisp 目录中被黑客攻击,您只需将以下内容添加到您的 .emacs 中:

(require 'server)
(并且(>= emacs-主要版本 23)
(defun server-ensure-safe-dir (dir) "Noop" t))

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

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

故事未完 2024-07-26 18:46:16

此外,您不希望服务器以批处理模式启动。
因此,在我的 .emacs 中,我使用了

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

然后

(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))

服务器功能仍然反复无常:server-start%HOME%/.emacs.d/server< 时抛出/em> 目录不存在。 接下来Emacs就无法再启动了! 显而易见的解决方案是创建丢失的目录并重试; 我在网上的某个地方找到了解决方案,但真的不记得在哪里。 以下代码在我的几台 Windows 计算机上成功运行多年:

(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))))
    )
  )

此代码在从棒上运行 Emacs 时也可以工作。

希望这可以帮助。

Additionally you do not want the server to be started in batch-mode.
In my .emacs I therefore 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))

Still the server feature is capricious: server-start throws when the %HOME%/.emacs.d/server directory does not exist. In succession Emacs won't start up again! The obvious solution is to create the missing directory and try again; I found the solution somewhere on the net but really can't remember where. The following code runs successfully for years now on several of my Windows machines:

(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 running Emacs from a stick.

Hope this helps.

孤君无依 2024-07-26 18:46:16

在 Windows 7 中对我不起作用。

相反,我阅读了 server-ensure-safe-dir 中的注释,并继续获取 %APPDATA% forlder 和子文件夹的所有权。 它们属于当地管理员,而不是我。

这有帮助!

Did not work for me in Windows 7.

I instead read the comments in server-ensure-safe-dir and proceeded with taking the ownership for %APPDATA% forlder and subfolders. They were owned by local Administrators, not by me.

That helped!

心碎的声音 2024-07-26 18:46:16

Givenkoa 的回答非常有帮助。 我在 Emacs 24.1、Windows 2003 上遇到了这个问题。

不幸的是,按照第一个代码片段中的建议,覆盖 server-ensure-safe-dir 成为 noop 并不在所有情况下都对我有用。 具体来说,在(服务器启动)至少执行一次之前应用它不起作用,因为初始执行也会创建目录(如果该目录不存在) 。 对于 noop 版本,根本不会创建该目录。

对我来说有效的解决方法是消除错误消息,同时仍然正确创建目录,它是以下代码,放在我的 Emacs 初始化文件中的 (server-start) 之前。 它在 server-ensure-safe-dir 周围提出了建议,以忽略从那里引发的任何错误。 没有解决问题的根本原因,但对我来说已经足够了。

(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))

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))
伤痕我心 2024-07-26 18:46:16

如果 RealityMonster 识别出服务器文件夹所有权问题,那么您可以在 Windows 命令提示符下运行此命令来修复它:

takeown /f %USERPROFILE%\.emacs.d\server /r /d y

If it's the server folder ownership issue that RealityMonster identified, then you can run this at the windows command prompt to fix it:

takeown /f %USERPROFILE%\.emacs.d\server /r /d y
苹果你个爱泡泡 2024-07-26 18:46:16

以下步骤对我有用:
1. 以 .reg 文件形式执行以下代码。 Emacs win 版本会将注册表中的任何值视为 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. 将以下代码添加到您的 .emacs/init.el 中。 这里的键应该是“server-auth-dir”。
(require 'server)
(setq server-auth-dir "~/server")  ;;Server file location
(setq server-name "main_server")   ;;Server mutex file name
(server-start)

通过上述步骤,服务器模式对我来说正确且完美。

Below step works for me:
1. Execute code below as .reg file. Emacs win version will treat any values in registry 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 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)

By steps above server mode works for me correctly and perfect.

相守太难 2024-07-26 18:46:16

如果这偶尔会影响到人们,我的工作站刚刚经历了“域迁移”,这为盒子上的每个文件添加了另一个权限,然后我开始收到此错误。 在我将表达式添加到虚拟“server-ensure-safe-dir”后,这不再失败。

(如果您想知道,迁移将分 2-3 个步骤。第一个在目标域中为我添加权限,然后我移动到目标域,然后他们可能(我不确定这一点) )删除旧域的权限。这是一家大公司,有很多用户,所以他们是分步进行的。)

In case this occasionally hits people, my workstation just went through a "domain migration", which added another permission to every file on the box, then I started getting this error. After I added the expression to dummy out "server-ensure-safe-dir" this stopped failing.

(If you're wondering, the migration will be in 2-3 steps. The first one adds the permission for me in the target domain, then I get moved to the target domain, then they might (I'm not sure about this) remove the permission for the old domain. It's a big company, and many users, so they're doing it in separate steps.)

把回忆走一遍 2024-07-26 18:46:16

上次我尝试时,“取得所有权”外壳扩展完成了这项工作

last time I tried, the "Take ownership" shell extension did the job

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文