From: Jim Porter <jporterbugs@gmail.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: Jordan Wilson <jordan.t.wilson@gmx.com>, 65551@debbugs.gnu.org
Subject: bug#65551: 29.1; Eshell on MS-Windows using plink: 'plink' is not recognized as an internal or external command...
Date: Mon, 28 Aug 2023 09:29:50 -0700 [thread overview]
Message-ID: <b45b2284-2386-7025-62e3-9817a2d86d78@gmail.com> (raw)
In-Reply-To: <877cpf31hs.fsf@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 560 bytes --]
On 8/28/2023 3:27 AM, Michael Albinus wrote:
> I've applied the following sledge-hammer patch, which cures the problem
> for me. But I'm pretty sure there are better ways in Eshell to fix this.
How about something like this? It's a little less invasive (but no less
of a hack).
I'll have to think about this more generally though, since I think
Eshell should be a lot more precise about how it handles environment
variables on remote hosts in general. Maybe we even want each host to
have its own distinct set of env vars. That would probably be safer...
[-- Attachment #2: 0001-Fix-remote-path-setting-in-Eshell.patch --]
[-- Type: text/plain, Size: 3475 bytes --]
From a433028e00e5dbe851fcb2df5cce35a8a91e8cc5 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 27 Aug 2023 12:53:40 -0700
Subject: [PATCH] Fix remote path setting in Eshell
This ensures that we supply Tramp with the local PATH so that it can
do its job of starting the local "ssh", or whatever the method uses
(bug#65551).
* lisp/eshell/esh-proc.el (eshell-gather-process-output): Add special
handling for remote processes.
* test/lisp/eshell/esh-proc-tests.el
(esh-var-test/remote/remote-path): New test.
---
lisp/eshell/esh-proc.el | 14 +++++++++++++-
test/lisp/eshell/esh-proc-tests.el | 15 +++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index fcd59ab9f37..5bd8446eeec 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -265,6 +265,8 @@ eshell-last-sync-output-start
"A marker that tracks the beginning of output of the last subprocess.
Used only on systems which do not support async subprocesses.")
+(defvar tramp-remote-path)
+
(defun eshell-gather-process-output (command args)
"Gather the output from COMMAND + ARGS."
(require 'esh-var)
@@ -272,7 +274,8 @@ eshell-gather-process-output
(unless (and (file-executable-p command)
(file-regular-p (file-truename command)))
(error "%s: not an executable file" command))
- (let* ((delete-exited-processes
+ (let* ((real-path (getenv "PATH"))
+ (delete-exited-processes
(if eshell-current-subjob-p
eshell-delete-exited-processes
delete-exited-processes))
@@ -280,6 +283,15 @@ eshell-gather-process-output
(coding-system-for-read coding-system-for-read)
(coding-system-for-write coding-system-for-write)
proc stderr-proc decoding encoding changed)
+ ;; HACK: We want to supply our subprocess with the all the
+ ;; environment variables we've set in Eshell. However, supplying
+ ;; a remote PATH this way can break Tramp, which needs the *local*
+ ;; PATH for calling "ssh", etc. Instead, set the local path in
+ ;; our `process-environment' and pass the remote PATH via
+ ;; `tramp-remote-path'.
+ (when (file-remote-p default-directory)
+ (push (concat "PATH=" real-path) process-environment)
+ (setq tramp-remote-path (eshell-get-path)))
;; MS-Windows needs special setting of encoding/decoding, because
;; (a) non-ASCII text in command-line arguments needs to be
;; encoded in the system's codepage; and (b) because many Windows
diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el
index 8e02fbb5497..7d0432dbe68 100644
--- a/test/lisp/eshell/esh-proc-tests.el
+++ b/test/lisp/eshell/esh-proc-tests.el
@@ -259,4 +259,19 @@ esh-proc-test/kill-pipeline-head
output-start (eshell-end-of-output))
"")))))
+\f
+;; Remote processes
+
+(ert-deftest esh-var-test/remote/remote-path ()
+ "Ensure that setting the remote PATH in Eshell doesn't interfere with Tramp.
+See bug#65551."
+ (skip-unless (and (eshell-tests-remote-accessible-p)
+ (executable-find "echo")))
+ (let ((default-directory ert-remote-temporary-file-directory))
+ (with-temp-eshell
+ (eshell-insert-command "set PATH ''")
+ (eshell-match-command-output
+ (format "%s hello" (executable-find "echo" t))
+ "\\`hello\n"))))
+
;;; esh-proc-tests.el ends here
--
2.25.1
next prev parent reply other threads:[~2023-08-28 16:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-26 14:11 bug#65551: 29.1; Eshell on MS-Windows using plink: 'plink' is not recognized as an internal or external command Jordan Wilson
2023-08-26 14:42 ` Eli Zaretskii
2023-08-26 14:48 ` Jordan Wilson
2023-08-26 15:12 ` Eli Zaretskii
2023-08-26 19:16 ` Jim Porter
2023-08-26 21:28 ` Jordan Wilson
2023-08-27 6:30 ` Jim Porter
2023-08-27 17:55 ` Michael Albinus
2023-08-27 17:50 ` Michael Albinus
2023-08-27 18:48 ` Jim Porter
2023-08-28 10:27 ` Michael Albinus
2023-08-28 16:29 ` Jim Porter [this message]
2023-08-28 16:47 ` Jim Porter
2023-08-28 16:53 ` Jim Porter
2023-08-28 17:40 ` Michael Albinus
2023-09-08 1:18 ` Jim Porter
2023-08-28 17:33 ` Michael Albinus
2023-08-28 18:01 ` Jim Porter
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b45b2284-2386-7025-62e3-9817a2d86d78@gmail.com \
--to=jporterbugs@gmail.com \
--cc=65551@debbugs.gnu.org \
--cc=jordan.t.wilson@gmx.com \
--cc=michael.albinus@gmx.de \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).