rsync fails when there's a space in the directory path

I'm trying to use Rsync to synchronize with a remote server. The rsync configuration says that the connection succeeds. 

However, when I attempt to synchronize with the remote, I get the following error. 

[12/20/2022 6:53 AM] Upload 'E:\projects\CMakeLists.txt' to '/home/user/CMakeLists.txt' using rsync
[12/20/2022 6:53 AM] "C:\Program Files\Git\usr\bin\rsync.exe" -zar -e "C:\Program Files\Git\usr\bin\ssh.exe -p 22 " -- 
[12/20/2022 6:53 AM] rsync: [sender] Failed to exec C:\Program: No such file or directory (2)
[12/20/2022 6:53 AM] rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.2.3]
[12/20/2022 6:53 AM] rsync: connection unexpectedly closed (0 bytes received so far) [sender]
[12/20/2022 6:53 AM] rsync error: error in rsync protocol data stream (code 12) at io.c(228) [sender=
[12/20/2022 6:53 AM] 3.2.3]

This suggests that the executed command isn't getting quoted properly. It's also possible this is a bug in rsync itself.

System Info

  • Clion 2022.3
  • Windows 11 Pro; Version 22H2; Build 22621.963
  • Git 2.38.1.windows.1
1

Hello!

Could you please try adding --protect-args to Rsync options? Does it help?

0

That doesn't resolve the issue (see error below). The issue isn't with rsync's options, it's with how rsync is being called. It's strange because the test button calls rsync just fine. That suggests there's two different bits of code calling the program.

[12/21/2022 7:39 AM] Automatic upload
[12/21/2022 7:39 AM] Upload 'E:\projects\main.cpp' to '/home/clion/restful-devices/main.cpp' using rsync
[12/21/2022 7:39 AM] "C:\Program Files\Git\usr\bin\rsync.exe" -zar --protect-args -e "C:\Program Files\Git\usr\bin\ssh.exe -p 22 " 
[12/21/2022 7:39 AM] rsync: [sender] Failed to exec C:\Program: No such file or directory (2)
[12/21/2022 7:39 AM] rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.2.3]
[12/21/2022 7:39 AM] rsync: connection unexpectedly closed (0 bytes received so far) [sender]
[12/21/2022 7:39 AM] rsync error: error in IPC code (code 14) at io.c(228) [sender=3.2.3]
[12/21/2022 7:39 AM] Failed to transfer folder 'E:\projects\main.cpp'. Unknown message with code "Rsync failed with exit code: 14".
[12/21/2022 7:39 AM] Automatic upload completed in 502 ms: 1 item failed

 

0

Your setup is quite specific. How did you add rsync to Git?

0

rsync comes with a standard install of Git for windows. My setup isn't that specific. I imagine there are many developers using this setup. Just not necessarily Clion. 

As I mentioned, in the settings dialog the 'test" button returns a success. But when it comes time to synchronize to the remote server, the command fails. 

0
  1. I tried installing Git for Windows from https://git-scm.com/download/win, and I didn't get rsync.exe in C:\Program Files\Git\usr\bin. What am I missing?
  2. What happens if you execute "C:\Program Files\Git\usr\bin\rsync.exe" -zar -e "C:\Program Files\Git\usr\bin\ssh.exe -p 22 " in console?

For me it looks like rsync itself is executed (thus the log has [12/21/2022 7:39 AM] rsync:), but can't properly handle "C:\Program Files\Git\usr\bin\ssh.exe -p 22 ".

0

I ran into the same issue today. I've created a ticket and also posted a workaround there.

I'm surprised with how few people reported this (well, I somehow only ran into this first time myself…).

0

请先登录再写评论。