WSL下 Debian emacs 29.1 emacsclient 无响应

目前使用的是Debian sid源中的emacs-gtk 29.1,发现之前一直能用的emacsclient没有响应了。

由于使用的是emacsclient,无法使用emacs -Q排查,所以我使用了备份.emacs.d然后删除.emacs.d的方式:

 rm -rf ~/.emacs.d && emacsclient -c -a "" -n
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/00debian.el (source)...done
Loading /etc/emacs/site-start.d/50asymptote.el (source)...
Loading /etc/emacs/site-start.d/50asymptote.el (source)...done
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50emacs-mozc.el (source)...
Loading /etc/emacs/site-start.d/50emacs-mozc.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Loading /usr/share/emacs/site-lisp/latex-cjk-common/cjk-enc.el (source)...
Loading /usr/share/emacs/site-lisp/latex-cjk-common/cjk-enc.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...done
Loading /etc/emacs/site-start.d/50latexmk.el (source)...
Loading /etc/emacs/site-start.d/50latexmk.el (source)...done
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...done
Starting Emacs daemon.
Emacs daemon should have started, trying to connect again

然而没有任何的frame出现,

ps aux | grep emacs
wang1zh+   350  0.0  0.0   6344  2076 pts/0    S+   00:55   0:00 grep emacs
wang1zh+ 30563  0.0  4.1 271852 168356 ?       Ss   Aug29   0:02 /usr/bin/emacs -no-comp-spawn -Q --batch --eval (setq w32-disable-abort-dialog t) -l /tmp/emacs-async-comp-flymake.el-6489E9.el
wang1zh+ 32715  0.1  1.1 183496 45872 ?        Ss   00:53   0:00 emacs --daemon

好像是在异步编译些什么;

如果使用emacsclient -c -a "" 倒是能正常弹出frame,但会占据这个terminal,在foreground运行:

 rm -rf ~/.emacs.d && emacsclient -c -a ""
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/00debian.el (source)...done
Loading /etc/emacs/site-start.d/50asymptote.el (source)...
Loading /etc/emacs/site-start.d/50asymptote.el (source)...done
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50emacs-mozc.el (source)...
Loading /etc/emacs/site-start.d/50emacs-mozc.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Loading /usr/share/emacs/site-lisp/latex-cjk-common/cjk-enc.el (source)...
Loading /usr/share/emacs/site-lisp/latex-cjk-common/cjk-enc.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...done
Loading /etc/emacs/site-start.d/50latexmk.el (source)...
Loading /etc/emacs/site-start.d/50latexmk.el (source)...done
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...done
Starting Emacs daemon.
Emacs daemon should have started, trying to connect again
Waiting for Emacs...Waiting for Emacs...

这里是通过上面方式打开的emacsclient中*Async-native-compile-log*的内容:

Compiling /usr/share/emacs/site-lisp/dictionaries-common/debian-ispell.el...

In debian-ispell-initialize-dicts-alist:
debian-ispell.el:420:16: Warning: reference to free variable ‘ispell-program-name’
debian-ispell.el:427:16: Warning: reference to free variable ‘ispell-dictionary’
debian-ispell.el:429:11: Warning: assignment to free variable ‘ispell-base-dicts-override-alist’
debian-ispell.el:437:24: Warning: reference to free variable ‘ispell-base-dicts-override-alist’

In debian-ispell-set-default-dictionary:
debian-ispell.el:475:9: Warning: reference to free variable ‘ispell-dictionary’
debian-ispell.el:489:18: Warning: reference to free variable ‘ispell-program-name’
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/cl-lib.el.gz...
uncompressing cl-lib.el.gz...
uncompressing cl-lib.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/wid-edit.el.gz...
uncompressing wid-edit.el.gz...
uncompressing wid-edit.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/icons.el.gz...
uncompressing icons.el.gz...
uncompressing icons.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/cus-edit.el.gz...
uncompressing cus-edit.el.gz...
uncompressing cus-edit.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/pp.el.gz...
uncompressing pp.el.gz...
uncompressing pp.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/cl-loaddefs.el.gz...
uncompressing cl-loaddefs.el.gz...
uncompressing cl-loaddefs.el.gz...done
Compiling /usr/share/emacs/site-lisp/debian-startup.el...
Compiling /usr/share/emacs/29.1/lisp/server.el.gz...
Compiling /usr/share/emacs/29.1/lisp/help-mode.el.gz...
uncompressing server.el.gz...
uncompressing server.el.gz...done
uncompressing help-mode.el.gz...
uncompressing help-mode.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/cl-extra.el.gz...
uncompressing cl-extra.el.gz...
uncompressing cl-extra.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/gv.el.gz...
uncompressing gv.el.gz...
uncompressing gv.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/cl-macs.el.gz...
uncompressing cl-macs.el.gz...
uncompressing cl-macs.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/cl-seq.el.gz...
uncompressing cl-seq.el.gz...
uncompressing cl-seq.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/rx.el.gz...
uncompressing rx.el.gz...
uncompressing rx.el.gz...done
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/subr-x.el.gz...
Compiling /usr/share/emacs/29.1/lisp/emacs-lisp/warnings.el.gz...
uncompressing subr-x.el.gz...
uncompressing subr-x.el.gz...done
uncompressing warnings.el.gz...
uncompressing warnings.el.gz...done
Compilation finished.
Compiling /usr/share/emacs/29.1/lisp/display-line-numbers.el.gz...
uncompressing display-line-numbers.el.gz...
uncompressing display-line-numbers.el.gz...done
Compilation finished.

*Message*

Loading /etc/emacs/site-start.d/00debian.el (source)...done
Loading /etc/emacs/site-start.d/50asymptote.el (source)...done
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50emacs-mozc.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Loading /usr/share/emacs/site-lisp/latex-cjk-common/cjk-enc.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...done
Loading /etc/emacs/site-start.d/50latexmk.el (source)...done
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...done
Starting Emacs daemon.
When done with this frame, type C-x 5 0

有什么头绪吗?

你没把 site-lisp 删了吗?


比较好奇为什么会出现 w32-disable-abort-dialog

emacs --daemon -Q 可以启动无配置的daemon.

尝试了先启动无配置的daemon:

❯ emacs -Q --daemon

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Starting Emacs daemon.
❯ emacsclient -c -a "" -n
❯ ps aux | grep emacs
wang1zh+   529  0.0  0.9 176516 37816 ?        Ss   10:40   0:00 emacs -Q --daemon
wang1zh+   558 50.0  0.0   6344  2084 pts/0    S+   10:41   0:00 grep emacs
wang1zh+ 30563  0.0  4.1 271852 168356 ?       Ss   Aug29   0:02 /usr/bin/emacs -no-comp-spawn -Q --batch --eval (setq w32-disable-abort-dialog t) -l /tmp/emacs-async-comp-flymake.el-6489E9.el

同样卡死在这个地方。

不知道有没有同样在WSL Debian sid下使用emacs并且平时用emacsclient的道友?还没有试过非wsl下的Debian是否会同样报错,我向Debian发了的bug report,但还没收到回复。

这个问题至今还是没有修复,论坛内有没有dd可以向上游汇报一下?

似乎是wsl的bug,见https://github.com/microsoft/wslg/issues/1127

暂时的修复方法:使用emacs-pgtk

道友用pgtk版本的话,从win复制中文到emacs里会乱码吗?

没有观察到乱码,但是有无法从emacs复制到windows的现象,解决方案见:

https://emacsredux.com/blog/2022/01/04/dealing-with-clipboard-issues-on-windows-11-wslg/

https://www.fredgruber.org/post/wsl_emacs_clipboard_2nd_solution/

https://www.fredgruber.org/post/wsl_emacs_clipboard/

倒是奇怪,我从emacs复制到win没有遇到过问题 :laughing:

请问你的环境是?

WSL2 Arch 用 vcxsrv来配合emacs+doom使用