Subject: Re: bug#42538: 28.0.50; tramp-test35-remote-path test timing out on macOS

From: Michael Albinus <[email-masked]>
Date: Wed, 29 Jul 2020 16:26:16 +0200

Michael Albinus <[email-masked]> writes:

Hi Philipp,

> As you see, Tramp is stalled for 19 seconds, and then the timeout kills
> it. I will see whether I could rearrange the command sequence. Maybe
> writing the temp file just in shorter chunks, or so.

Could you pls check, whether the appended patch works for you?

Thanks, and best regards, Michael.

*** /tmp/ediffER3tRj	2020-07-29 16:25:21.006042133 +0200
--- /home/albinus/src/tramp/lisp/tramp-sh.el	2020-07-29 14:00:29.606271640 +0200
***************
*** 4009,4025 ****
  	 (with-tramp-connection-property vec "pipe-buf"
  	   (tramp-send-command-and-read
  	    vec "getconf PIPE_BUF / 2>/dev/null || echo 4096" 'noerror)))
! 	tmpfile)
      (tramp-message vec 5 "Setting $PATH environment variable")
      (if (< (length command) pipe-buf)
  	(tramp-send-command vec command)
!       ;; Use a temporary file.
!       (setq tmpfile (tramp-make-tramp-temp-file vec))
!       (tramp-send-command vec (format
! 			       "cat >%s <<'%s'\n%s\n%s"
! 			       (tramp-shell-quote-argument tmpfile)
! 			       tramp-end-of-heredoc
! 			       command tramp-end-of-heredoc))
        (tramp-send-command vec (format ". %s" tmpfile))
        (tramp-send-command vec (format "rm -f %s" tmpfile)))))

--- 4009,4031 ----
  	 (with-tramp-connection-property vec "pipe-buf"
  	   (tramp-send-command-and-read
  	    vec "getconf PIPE_BUF / 2>/dev/null || echo 4096" 'noerror)))
! 	tmpfile chunk chunksize)
      (tramp-message vec 5 "Setting $PATH environment variable")
      (if (< (length command) pipe-buf)
  	(tramp-send-command vec command)
!       ;; Use a temporary file.  We cannot use `write-region' because
!       ;; setting the remote path happens in the early connection
!       ;; handshake, and not all external tools are determined yet.
!       (setq command (concat command "\n")
! 	    tmpfile (tramp-make-tramp-temp-file vec))
!       (while (not (string-empty-p command))
! 	(setq chunksize (min (length command) (/ pipe-buf 2))
! 	      chunk (substring command 0 chunksize)
! 	      command (substring command chunksize))
! 	(tramp-send-command vec (format
! 				 "echo -n %s >>%s"
! 				 (tramp-shell-quote-argument chunk)
! 				 (tramp-shell-quote-argument tmpfile))))
        (tramp-send-command vec (format ". %s" tmpfile))
        (tramp-send-command vec (format "rm -f %s" tmpfile)))))