Subject: Re: bug#68976: 30.0.50; Tramp: unexpected error when calling (file-remote-p "/dav:localhost#8000:/foo")

From: Michael Albinus <[email-masked]>
Date: Wed, 07 Feb 2024 18:59:48 +0100

Ihor Radchenko <[email-masked]> writes:

> Hello,

Hi Ihor,

> Today, I tried to execute an innocent test checking if a file is remote
> or not:
>
> (file-remote-p "/dav:localhost#8000:/foo")
>
> Unexpectedly, I encountered user error
> tramp-error: Package `tramp-gvfs' not supported
>
> I did not expect that `file-remote-p' should ever throw an error other
> than when passed non-string argument.

You are right. It should have returned nil instead of the
error. `file-remote-p' claims in its docstring

--8<---------------cut here---------------start------------->8---
Test whether FILE specifies a location on a remote system.
--8<---------------cut here---------------end--------------->8---

> Looking at the code, (setq tramp-gvfs-enabled t) would make the error
> disappear. (The default value is nil)

If tramp-gvfs-enabled is nil (default value if D-Bus is not enabled),
the example given above does not specify "a location on a remote system".

> I believe that it is inappropriate that throw an error in such
> situation. If "gvfs" is not supported, but still claimed to be remote by
> TRAMP, I expect non-nil return value when calling `file-remote-p'; not
> an error.

Tramp does not claim it is remote. However, it should return nil.

If you want to know, whether a file name has remote file name syntax,
you should call

(string-match-p tramp-file-name-regexp "/dav:localhost#8000:/foo")

This variable is documented in the Tramp manual, node "(tramp) Change
file name syntax".

I will fix it on master (returning nil but an error).

Best regards, Michael.