Subject: Re: bug#79103: 31.0.50; Tramp ssh method doesn't work

From: Michael Albinus <[email-masked]>
Date: Sun, 27 Jul 2025 14:08:18 +0200

Michael Albinus <[email-masked]> writes:

Hi Bernardo,

>> It's a bit odd as this setup has been in place for a long time but has
>> caused the problem only now; i can live without colours (or temporarily
>> disabling them). Had a misconception that PS1 settings on the *target*
>> host are important and have accordingly stripped it down to bare minimum
>> but with no effect.
>
> PS1 setting is relevant for both the local and remote case.
>
>> Thanks for your help, guess the case is closed.
>
> Yep, I'm closing it.

Just one test, please. Could you apply the appended patch to your Emacs?
Hopefully, the behavior will be as before, and you don't need to worry
about setting the local PS1.

Best regards, Michael.

diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index 896f7057..576f09b7 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -5215,7 +5215,6 @@ connection if a previous connection has died for some reason."
 	      ;; Start new process.
 	      (when (and p (processp p))
 		(delete-process p))
-	      (setenv "TERM" tramp-terminal-type)
 	      (setenv "LC_ALL" (tramp-get-local-locale vec))
 	      (if (stringp tramp-histfile-override)
 		  (setenv "HISTFILE" tramp-histfile-override)
@@ -5224,8 +5223,6 @@ connection if a previous connection has died for some reason."
 		      (setenv "HISTFILE")
 		      (setenv "HISTFILESIZE" "0")
 		      (setenv "HISTSIZE" "0"))))
-	      (setenv "PROMPT_COMMAND")
-	      (setenv "PS1" tramp-initial-end-of-output)
 	      (unless (stringp tramp-encoding-shell)
                 (tramp-error vec 'file-error "`tramp-encoding-shell' not set"))
 	      (let* ((current-host tramp-system-name)
diff --git a/lisp/tramp.el b/lisp/tramp.el
index 6c501a3e..2208ce88 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -6880,9 +6880,11 @@ might have improper values."
 	  (mapcar #'car tramp-connection-local-default-system-variables))))
     `(let* ((default-directory tramp-compat-temporary-file-directory)
 	    (temporary-file-directory tramp-compat-temporary-file-directory)
-	    (process-environment
-	     (cons "TERM=dumb" (default-toplevel-value 'process-environment)))
             ,@bindings)
+       (setenv "TERM" tramp-terminal-type)
+       (setenv "PROMPT_COMMAND")
+       (setenv "PS1" tramp-initial-end-of-output)
+       (setenv "INSIDE_EMACS" (tramp-inside-emacs))
        ,@body)))
 
 (defun tramp-start-process (vec name buffer program &rest args)