Subject: Re: bug#48067: 28.0.50; Tramp error: cannot determine gio monitor

From: Michael Albinus <[email-masked]>
Date: Thu, 29 Apr 2021 10:11:50 +0200

Thierry Volpiatto <[email-masked]> writes:

> Update2:
> More exactly the error occur when setting 'string':
>
> diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
> index 4a3072ee346..8885bd55846 100644
> --- a/lisp/net/tramp-sh.el
> +++ b/lisp/net/tramp-sh.el
> @@ -3748,7 +3748,8 @@ Supported arguments for GIO_USE_FILE_MONITOR environment variable:
>             (intern
>  	    (format "G%sFileMonitor" (capitalize (match-string 1 string)))))
>            (t (throw 'doesnt-work nil))))
> -	(setq string (substring string (match-end 0))))
> +	;(setq string (substring string (match-end 0)))
> +        )
>
>        ;; Delete empty lines.
>        (setq string (tramp-compat-string-replace "\n\n" "\n" string)
>
> With this commented line events occur as expected.

So the problem is the match-end call. Here's a patch which might fix
this. In case it doesn't work, pls give me ssh access to your machine. I
would send you my public ssh key for access.

Best regards, Michael.

diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index 4a3072ee..4506e8a2 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -3732,23 +3732,24 @@ Fall back to normal file name handler if no Tramp handler exists."
       (unless (tramp-connection-property-p proc "gio-file-monitor")
         (tramp-set-connection-property
          proc "gio-file-monitor"
-         (cond
-          ;; We have seen this on cygwin gio and on emba.  Let's make
-          ;; some assumptions.
-          ((string-match
-            "Can't find module 'help' specified in GIO_USE_FILE_MONITOR" string)
-           (cond
-            ((getenv "EMACS_EMBA_CI") 'GInotifyFileMonitor)
-            ((eq system-type 'cygwin) 'GPollFileMonitor)
-            (t tramp-cache-undefined)))
-          ;; TODO: What happens, if several monitor names are reported?
-          ((string-match "\
+	 (prog1
+             (cond
+              ;; We have seen this on cygwin gio and on emba.  Let's make
+              ;; some assumptions.
+              ((string-match "\
+[^z-a]*Can't find module 'help' specified in GIO_USE_FILE_MONITOR" string)
+               (cond
+		((getenv "EMACS_EMBA_CI") 'GInotifyFileMonitor)
+		((eq system-type 'cygwin) 'GPollFileMonitor)
+		(t nil)))
+              ;; TODO: What happens, if several monitor names are reported?
+              ((string-match "\
 Supported arguments for GIO_USE_FILE_MONITOR environment variable:
 \\s-*\\([[:alpha:]]+\\) - 20" string)
-           (intern
-	    (format "G%sFileMonitor" (capitalize (match-string 1 string)))))
-          (t (throw 'doesnt-work nil))))
-	(setq string (substring string (match-end 0))))
+               (intern
+		(format "G%sFileMonitor" (capitalize (match-string 1 string)))))
+              (t (throw 'doesnt-work nil)))
+	   (setq string (substring string (match-end 0))))))

       ;; Delete empty lines.
       (setq string (tramp-compat-string-replace "\n\n" "\n" string)