From: Oleksandr Gavenko <gavenkoa@gmail.com>
To: cygwin@cygwin.com
Subject: Help with setting Cygwin's Emacs W32 TRAMP to WSL 1
Date: Thu, 26 Nov 2020 17:18:37 +0200 [thread overview]
Message-ID: <CAFNJpniCb6AMojTH=MCK=tNqWuOxS64ie=5UV5A8zyJAY2UWYw@mail.gmail.com> (raw)
I'm using Cygwin for two reasons: mintty + Emacs w32.
Nowadays WSL 1 has become important (vendors provide ready to work
.deb packages,
I use: Ansible + Google Cloud SDK, if name any).
Still WSL 1 lacks UI and integrates less smoothly into my workflow
to replace Cygwin's amazing Emacs W32.
WSL1 files are "hidden" for regular access.
Emacs has TRAMP mode to access foreign environments:
https://www.gnu.org/software/tramp/
I tried to define configuration that should have allowed to access WSL 1
from Cygwin's Emacs via "wsl sh" jump (the way TRAMP support "su" &
"sudo" jumps):
* https://www.reddit.com/r/emacs/comments/jrkgmy/tramp_for_wsl_1_from_cygwin_emacsw32/
* https://github.com/microsoft/WSL/issues/6236
- wsl.exe periodically sends control characters making impossible "piping"
via interactive/terminal mode
The problem is that when Cygwin's Emacs invokes "wsl.exe" conhost or
wsl?? thinks
it is in a PTY mode and sends different "clearing" terminal escape
sequences (see WSL issue report).
I reproduce garbage with Elisp code:
(setq xxx (make-process :name "xxx" :buffer "xxx" :command '("wsl"
"echo" "OK") :connection-type 'pty))
(stop-process xxx)
Note that changing the last argument "pty" => "pipe" solves the problem,
but things are a bit complicated...
TRAMP mode has been implemented via call to "sh" by internal API "make-process".
And then TRAMP sends "wsl ..." to the shell so WSL thinks it is in
PTY and I have no way
to influence that decision ((
I tried stupid tricks like passing everything related to "ws.exe" via
pipe to "cat":
(with-eval-after-load 'tramp
(setf (alist-get "wsl" tramp-methods nil nil #'equal)
'((tramp-login-program "sh")
(tramp-login-args (("-c") ("wsl") ("-u" "%u") ("-d" "%h")
("|" "cat")))
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-c"))
(tramp-connection-timeout 10)
(tramp-session-timeout 300))))
or define a wrapper script that has "wsl ... | cat" inside. Nothing helped.
Few experiments with Cygwin's Expect also failed as I forgot
everything about that obscure tech...
So I need to write some wrapper that will bidirectionally pipe to "wsl.exe"
putting wsl into piped instead TTY mode.
It can be that there is a ready solution.
If not please advise which API should I use to write such a wrapper.
Should it be Cygwin's pipe/dup2/fork/execvp or popen?
Or should it be Windows native CreateChildProcess / WriteToPipe /
ReadFromPipe as here:
https://docs.microsoft.com/en-us/windows/win32/procthread/creating-a-child-process-with-redirected-input-and-output
Please CC me in replies, I'll check the mail archive after a week to
not lose any responses.
next reply other threads:[~2020-11-26 15:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-26 15:18 Oleksandr Gavenko [this message]
2020-11-26 15:24 ` Eliot Moss
2020-11-26 20:38 ` Oleksandr Gavenko
2020-11-27 18:12 ` Eliot Moss
2020-11-28 14:07 ` Oleksandr Gavenko
2020-11-26 18:42 ` Henry S. Thompson
2020-11-26 19:22 ` Oleksandr Gavenko
2020-11-26 20:02 ` Oleksandr Gavenko
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='CAFNJpniCb6AMojTH=MCK=tNqWuOxS64ie=5UV5A8zyJAY2UWYw@mail.gmail.com' \
--to=gavenkoa@gmail.com \
--cc=cygwin@cygwin.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).