Subject: bug#77402: 31.0.50; Tramp: file-writable-p broken

From: Gerd Möllmann <[email-masked]>
Date: Mon, 31 Mar 2025 18:15:58 +0200

Michael Albinus <[email-masked]> writes:

> Gerd Möllmann <[email-masked]> writes:
>
> Hi Gerd,
>
>>> Just wait! There's another nuisance worth to fix. Could you, pls, check?
>>
>> I'm afraid that's also not it. I can now boil it down to the following
>> test with emacs -Q (I'm always building without window system FWIW):
>>
>>   (file-writable-p "/ssh:mini:/tmp")
>>    => nil
>>   (file-writable-p (file-truename "/ssh:mini:/tmp"))
>>    => t
>>
>> where
>>
>>   (file-truename "/ssh:mini:/tmp")
>>    => "/ssh:mini:/private/tmp"
>
> Yes, this is the area I'm looking at. "/ssh:mini:/tmp" has file
> permissions lrwxr-xr-x, and "/ssh:mini:/private/tmp" has file
> permissions drwxrwxrwt. (file-writable-p "/ssh:mini:/tmp") should look
> at the permissions of the target, but it doesn't. It looks at the
> permissions of the symlink itself.

That's what I suspected..

> And everything is mixed happily with cached values, for performance
> speedup ...

...and there I got stuck :-)

>
>> Weird. With
>>
>>   (trace-function 'tramp-sh-handle-file-writable-p)
>>
>> I can see that this comes out of that function.
>>
>> Giving you access to "mini" is not an easy option, I'm afraid. It means
>> fighting with macOS network security, an area that I have virtually 0
>> experience with :-(.
>>
>> Anyway, maybe I can debug this. Or, I just change /tmp to not be
>> symlink, or maybe I can just set TMPDIR or something. Or, I just ssh and
>> run Emacs on the remote machine, with 0 work :-).
>
> OK, I'll continue to understand what happens. In the meantime, you might
> be better with setting tramp-use-file-attributes to nil, globally. At
> least it doesn't use the caches then.

Yeah, (setq tramp-use-file-attributes nil) makes it work. Thanks!