Emacs - 调用时出错(服务器启动)
我目前在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
我在 EmacsWiki 上找到了这个解决方案:
它绝对可以在 Vista 和 Emacs 23.2.1 上运行。
I found this solution on the EmacsWiki:
It definitely works on Vista, with Emacs 23.2.1.
我喜欢回答 larsreed,但完整的代码可供使用:
我在我的博客文章中讨论了这个问题 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 分区):I enjoy to anwer of larsreed, but complite code ready to use:
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):这是 Windows 上已知的 Emacs 错误。 解决方法是注释掉这一行
server.el 中的 server-ensure-safe-dir 更改后您需要字节重新编译:
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:
为了避免在 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))
此外,您不希望服务器以批处理模式启动。
因此,在我的 .emacs 中,我使用了
然后
服务器功能仍然反复无常:
server-start
在 %HOME%/.emacs.d/server< 时抛出/em> 目录不存在。 接下来Emacs就无法再启动了! 显而易见的解决方案是创建丢失的目录并重试; 我在网上的某个地方找到了解决方案,但真的不记得在哪里。 以下代码在我的几台 Windows 计算机上成功运行多年:此代码在从棒上运行 Emacs 时也可以工作。
希望这可以帮助。
Additionally you do not want the server to be started in batch-mode.
In my .emacs I therefore use
and then
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:This code also works when running Emacs from a stick.
Hope this helps.
在 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!
Givenkoa 的回答非常有帮助。 我在 Emacs 24.1、Windows 2003 上遇到了这个问题。
不幸的是,按照第一个代码片段中的建议,覆盖 server-ensure-safe-dir 成为 noop 并不在所有情况下都对我有用。 具体来说,在(服务器启动)至少执行一次之前应用它不起作用,因为初始执行也会创建目录(如果该目录不存在) 。 对于 noop 版本,根本不会创建该目录。
对我来说有效的解决方法是消除错误消息,同时仍然正确创建目录,它是以下代码,放在我的 Emacs 初始化文件中的 (server-start) 之前。 它在 server-ensure-safe-dir 周围提出了建议,以忽略从那里引发的任何错误。 没有解决问题的根本原因,但对我来说已经足够了。
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.
如果 RealityMonster 识别出服务器文件夹所有权问题,那么您可以在 Windows 命令提示符下运行此命令来修复它:
If it's the server folder ownership issue that RealityMonster identified, then you can run this at the windows command prompt to fix it:
以下步骤对我有用:
1. 以 .reg 文件形式执行以下代码。 Emacs win 版本会将注册表中的任何值视为 Env Var。
通过上述步骤,服务器模式对我来说正确且完美。
Below step works for me:
1. Execute code below as .reg file. Emacs win version will treat any values in registry as Env Var.
By steps above server mode works for me correctly and perfect.
如果这偶尔会影响到人们,我的工作站刚刚经历了“域迁移”,这为盒子上的每个文件添加了另一个权限,然后我开始收到此错误。 在我将表达式添加到虚拟“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.)
上次我尝试时,“取得所有权”外壳扩展完成了这项工作
last time I tried, the "Take ownership" shell extension did the job