Skip to content

--dry-run doesn't work with --mkpath when copying files #880

@pkzc

Description

@pkzc

When I try dry-running rsync for a single file (gitconfig) I get this:

+ rsync --dry-run --recursive --mkpath --links --perms --times --omit-dir-times /home/peter/src/gitlab/gkwf/home/.config/git/gitconfig /tmp/usr/local/share/git/gitconfig
rsync: [Receiver] change_dir#3 "/tmp/usr/local/share/git" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(829) [Receiver=3.4.1]
+ set +x

I know that the canonical answer is that I should do this:

+ rsync --dry-run --recursive --mkpath --links --perms --times --omit-dir-times /home/peter/src/gitlab/gkwf/home/.config/git/gitconfig /tmp/usr/local/share/git/
+ set +x

But my real goal is to copy the file by another name to the destination:

+ rsync --dry-run --recursive --mkpath --links --perms --times --omit-dir-times /home/peter/src/gitlab/gkwf/home/.config/git/gitconfig /tmp/usr/local/share/git/config
rsync: [Receiver] change_dir#3 "/tmp/usr/local/share/git" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(829) [Receiver=3.4.1]
+ set +x

The latter nicely succeeds in a live run:

+ rsync --recursive --mkpath --links --perms --times --omit-dir-times /home/peter/src/gitlab/gkwf/home/.config/git/gitconfig /tmp/usr/local/share/git/config
+ set +x
$ ls /tmp/usr/local/share/git/
config

That is I am unable to verify with a dry run a legitimate rsync operation which eventually, as it turns out, works perfectly. I also checked the destination directory with the help of chattr: rsync does not modify it in the course of the dry runs, therefore I feel it unjust that rsync treats destination files and destination directories differently during dry runs.

Environment:

$ rpm -q rsync
rsync-3.4.1-5.fc43.x86_64

$ uname -srv
Linux 6.19.13-200.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Apr 18 20:20:44 UTC 2026

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions