GNU bug report logs - #65812
29.1; Emacs client on Windows can't connect to the daemon on WSL over TCP

Previous Next

Package: emacs;

Reported by: user <at> pontos

Date: Thu, 7 Sep 2023 20:49:02 UTC

Severity: normal

Found in version 29.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: user <at> pontos
Cc: 65812 <at> debbugs.gnu.org
Subject: bug#65812: 29.1; Emacs client on Windows can't connect to the daemon on WSL over TCP
Date: Fri, 08 Sep 2023 10:24:25 +0300
> Date: Thu, 7 Sep 2023 15:10:59 -0400
> From: user <at> pontos
> 
> I'm trying to connect Emacs client running on Windows over TCP to the Emacs
> server running inside WSL.

This is currently not supported, due to the various quirks and kludges
we need to support the client-server protocol on MS-Windows.  the
patch below attempts to support this by adding one more kludge.

> # Inside WSL shell:
> (cat <<EOF
> (setq server-host "WSL_IP_ADDRESS_HERE")
> (setq server-port 12345)
> (setq server-use-tcp t)
> (server-start)
> EOF
> ) > server-config.el
> emacs -Q -l server-config.el --daemon
> 
> # On Windows
> # Map network drive \\wsl.localhost\Ubuntu as, e.g. W:
> # Then in PowerShell:
> $env:EMACS_SERVER_FILE=W:\home\user\.emacs.d\server\server
> & 'C:\Program Files\Emacs\emacs-29.1\bin\emacsclientw.exe' -c -n
> 
> Client will first display message window saying that it connected to the
> remote socket, and after clicking [OK] button, error message appears
> saying "*ERROR*: Could not open file: CONOUT$".

Please try the patch below and tell if it solves your problem.  The
patch should be applied to the Emacs you run inside WSL, and you will
need to byte-compile the patched server.el there, ensure the produced
server.elc file replaces the one you installed with the original Emacs
on WSL, and if Emacs you run on WSL also uses native-compilation, make
sure the stale .eln file is not loaded (it should happen
automatically, but for good measure just delete the old .eln file).

diff --git a/lisp/server.el b/lisp/server.el
index 104fc06..ee80b93 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1262,9 +1262,12 @@ server-process-filter
                  ;; choice there.)  In daemon mode on Windows, we can't
                  ;; make tty frames, so force the frame type to GUI
                  ;; there too.
-                 (when (and (eq system-type 'windows-nt)
-                            (or (daemonp)
-                                (eq window-system 'w32)))
+                 (when (or (and (eq system-type 'windows-nt)
+                                (or (daemonp)
+                                    (eq window-system 'w32)))
+                           ;; Client runs on Windows, but the server
+                           ;; runs on a Posix host.
+                           (equal tty-name "CONOUT$")
                    (push "-window-system" args-left)))
 
                 ;; -position +LINE[:COLUMN]:  Set point to the given




This bug report was last modified 1 year and 246 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.