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: Richard Stallman <[email-masked]>
Date: Thu, 26 Jun 2025 22:50:52 -0400

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > 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.

That difference, renaming vs copying, may be the reason why Tramp runs
into a problem trying to do chmod.  For Emacs, it is actually the
initial output _name_ which is temporary; that output file will
remain, once renamed, under the final name.

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?

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)