GNU bug report logs -
#78638
30.1; When editing a remote file owned by another user, Tramp signals an error because it cannot change the file mode
Previous Next
Full log
Message #8 received at 78638 <at> debbugs.gnu.org (full text, mbox):
> Date: Thu, 29 May 2025 21:09:31 +0000
> From: Michael McClennen via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
>
> Current behavior of Emacs
> -------------------------
>
> 1. Use Tramp to edit any remote file owned by a different user, where the
> file mode allows you to write to it.
>
> 2. Make a change to the file, and then save it.
>
> 3. The changes are saved, but the following error is thrown:
> "Error while changing file’s mode /scp:[hostname]:[filename]"
>
> 4. Make another change to the file, and save it again.
>
> 5. Emacs asks "[filename] has changed since it was last visited or
> saved. Save anyway?". This message is incorrect, since the file
> contents have not changed and were in fact saved correctly. Presumably, this
> question is triggered because the file mode is different than expected,
> but this particular case should not trigger this question.
>
> Expected behavior
> -----------------
>
> 1. Use Tramp to edit any remote file owned by a different user, where
> the file mode allows you to write to it.
>
> 2. Make a change to the file, and then save it.
>
> 3. The changes should be saved, and no error should be thrown. Perhaps
> the Tramp code could check whether the owner is different, and ignore
> the file mode if that is the case.
>
> 4. Make another change to the file, and save it again.
>
> 5. The save should occur without any questions, provided that the contents of
> the file have not changed on the remote server since the file was last
> visited or saved.
>
> Why this is important
> ---------------------
>
> When editing collaboratively with a remote partner, it is important that
> Emacs should tell me truthfully whether or not my partner has changed
> the file before I save it. If Tramp always flags a file owned by my
> partner as having been changed since I saved it, I have no way to know
> whether that is actually true or not.
Please read the node "Backup Copying" in the Emacs user manual. I
think Emacs behaves as expected in this case, because the default
method of saving a file also makes you the owner of the file, and that
is not always allowed when you edit files owned by a different user
(presumably in a directory owned by that user). What you need in
these cases is to set either backup-by-copying to t or
backup-by-copying-when-mismatch to nil (and perhaps increase
backup-by-copying-when-privileged-mismatch to a very large number), so
that backup files are created by copying and not by renaming.
This bug report was last modified 31 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.