Subject: Re: bug#65551: 29.1; Eshell on MS-Windows using plink: 'plink' is not recognized as an internal or external command...

From: Jim Porter <[email-masked]>
Date: Sat, 26 Aug 2023 23:30:05 -0700

On 8/26/2023 2:28 PM, Jordan Wilson wrote:
> Hi Jim,
> 
> On 2023-08-26 (Sat) at 12:16 (-0700), Jim Porter <[email-masked]> wrote:
>> Thanks for reporting this. I can reproduce this issue. Does evaluating the
>> following work?
>>
>>    (setf (alist-get 'tramp-login-program
>>                     (alist-get "plink" tramp-methods nil nil #'equal))
>>          (list (concat "\"" (executable-find "plink") "\"")))
>>
>> If so, I think I've identified the bug: in 'eshell-gather-process-output', we
>> set the 'process-environment' to Eshell's environment variables. In a remote
>> directory, this includes the remote PATH. However, that confuses Tramp, which
>> uses that remote PATH to look for the local "plink.exe".
> 
> I can confirm that snippet does resolve the problem.

Thanks for checking. That's probably the best way to get things working 
for now, but I'll make sure to get a fix for this in for Emacs 29.2. In 
the meantime, here's a regression test that we should be able to use to 
verify the fix once we have it.

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))
                     "")))))
 
+
+;; 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