-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Description
When using MSYS2 rsync (rsync 3.4.1 from Git for Windows) with the -e flag and a remote destination containing an MSYS2-style path (e.g., /c/Users/...), rsync fails with:
rsync error: syntax or usage error (code 1) at main.c(1415) [Receiver=3.4.1] - The source and destination cannot both be remote.
This happens because MSYS2 path conversion converts the /c/ portion of the remote destination path (user@host:/c/path) and rsync then misinterprets the remote path as a local path, triggering the error.
Steps to Reproduce
On a Windows machine with Git for Windows (MSYS2 rsync):
# FAILS with 'source and destination cannot both be remote':
rsync -az -e "ssh -p 2222" "/c/Users/test/file.txt" "user@host:/c/Users/test/"
# WORKS correctly (using RSYNC_RSH env var instead of -e flag):
RSYNC_RSH="ssh -p 2222" rsync -az "/c/Users/test/file.txt" "user@host:/c/Users/test/"Note: The remote side must have rsync installed (e.g., cwrsync) for the connection to succeed once the path bug is bypassed.
Expected Behavior
Both invocation styles (-e flag and RSYNC_RSH env var) should behave identically. The -e flag should pass the remote path unchanged to SSH/rsync on the remote side.
Root Cause Analysis
The issue appears to be in how MSYS2's path conversion layer handles arguments when rsync spawns the remote shell via -e. When the remote path argument containing /c/ (MSYS2 Windows drive path format) is passed through the MSYS2 runtime's spawn() or exec() call, the path conversion converts the /c/ portion before rsync can pass it to the SSH process unchanged. This causes rsync to misinterpret user@host:/c/path as having a local path component.
Workaround
Use RSYNC_RSH environment variable instead of the -e flag:
export RSYNC_RSH="ssh -p 2222 -i /c/Users/.ssh/id_rsa"
rsync -az /c/Users/local/path/ user@host:/c/Users/remote/path/Environment
- OS: Windows 10/Server (MSYS2/Git for Windows)
- rsync: 3.4.1 (from Git for Windows bundled MSYS2)
- SSH: OpenSSH_for_Windows_9.x
- MSYS2 runtime version: (please fill in)