all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: user@pontos
Cc: 65812@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	[thread overview]
Message-ID: <83bkedxh3q.fsf@gnu.org> (raw)
In-Reply-To: <yu4x2mrwsjl2ky5ysq4yx5lx3g46oxh6eptbw5hccrxbihu75k@dvhmyeb2unbx> (user@pontos)

> Date: Thu, 7 Sep 2023 15:10:59 -0400
> From: user@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





  reply	other threads:[~2023-09-08  7:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 19:10 bug#65812: 29.1; Emacs client on Windows can't connect to the daemon on WSL over TCP Unknown
2023-09-08  7:24 ` Eli Zaretskii [this message]
2023-09-08 11:18   ` Eli Zaretskii
2023-09-08 11:50     ` Eli Zaretskii
2023-09-15  7:04       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bkedxh3q.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=65812@debbugs.gnu.org \
    --cc=user@pontos \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.