Subject: bug#78638: 30.1; When editing a remote file owned by another user, Tramp signals an error because it cannot change the file mode

From: Michael Albinus <[email-masked]>
Date: Tue, 08 Jul 2025 09:31:07 +0200

Richard Stallman <[email-masked]> writes:

Hi Richard,

>   > > When Emacs saves a file directly, its preferred method is to write the
>   > > file under another name and then ewnames it into the desired name.
>   > > That is to avoid problems like this.
>
>   > This is what Tramp does. It writes the file to a local temporary name,
>   > and copies it then to the remote side.
>
> Those two methods are different in a crucial way.  Whan Emacs usually
> does is _rename_ the temporary file, which it has written in the
> destination directory, to the desired name.  It sounds like Tramp
> writes a temporary file in the local machine, then _copies_ the
> temporary file to the desired name in the destination directory.
>
> Is it possible for Tramp to write the output into a remote file
> in the intended remote directory, then rename it to the intended
> file name?

Tramp writes a local temporary file for a reason: In general, Emacs
cannot write a file to the remote host directly. It needs external help
(like scp and alike) to transfer a local file to the remote side.

Tramp could write a local temporary file, transfer it to a remote
temporary file, and rename the remote temporary file to the intended
file name. But this would require an additional step, which will be not
acceptable for performance reasons.

Note, that the root case of this bug was Tramp calling chmod, not the
copying action itself. Annoying, but not the end of the word.

Best regards, Michael.