I was trying to copy my some of my config folders to another system which was mounted with root privileges using dired. I opened both surrounding folders using /sudo::/... and tried to copy my files from one to the other, putting again the tramp-sudo-prefix into the copy path and was asked whether to overwrite the target folder, but when I said yes, it still told me copying failed because the folders already existed. I also tried using the dired-toggle-sudo-package, but it didn't work either. If I delete the folders to be overwritten before, I can copy the folders to the destination, but this is quite cumbersome. Is there a way I can overwrite the files without having to delete them first?

Here is an example of the output:

Overwrite ‘/sudo:root@alex:/run/media/alex/0c989fa2-cf7a-4238-b66d-4505fbac04f7/home/alex/Documents’? [Type ynlq! or C-h] y
File already exists: /sudo:root@alex:/run/media/alex/0c989fa2-cf7a-4238-b66d-4505fbac04f7/home/alex/Documents
Copy: ‘/sudo:root@alex:/home/alex/Documents’ to ‘/sudo:root@alex:/run/media/alex/0c989fa2-cf7a-4238-b66d-4505fbac04f7/home/alex/’ failed:
(file-already-exists /sudo:root@alex:/run/media/alex/0c989fa2-cf7a-4238-b66d-4505fbac04f7/home/alex/Documents)

I'm using Emacs 28.2 and Tramp

  • 1
    Could you give an example? There are subtle differences in overwriting files, depending on whether the target is a directory or not, and whether the target has a trailing slash when it is a directory. Pls show also the Emacs and Tramp versions you use. Commented May 9, 2023 at 9:23
  • @MichaelAlbinus I added example output and version information to the post. Commented May 9, 2023 at 9:36

1 Answer 1


I can reproduce the problem with Emacs 28.3 / Tramp 2.5.4-pre. Running the very same recipe with Emacs 29.0.90 / Tramp works as expected.

Emacs 29.1 is in pretest. So I recommend for the time being to install Tramp from GNU ELPA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.