使用rsync推送本地目录至EC2实例报错求助
问题描述
我在本地机器上有一个目录,想要将其推送到EC2实例,相关目录结构如下:
我使用rsync执行了以下命令:
rsync /Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2/ ubuntu@10.104.35.171:/srv/shiny-server/DataScience/Senior/AbrCallAppTrending rsync -azu /Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2/ ubuntu@10.104.35.171:/srv/shiny-server/DataScience/Senior/AbrCallAppTrending
两条命令均返回如下错误:
abr032296@LAP109053:/mnt/c/Users/abr032296$ rsync /Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2/ ubuntu@10.104.35.171:/srv/shiny-server/DataScience/Senior/AbrCallAppTrending rsync: change_dir "/Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3] abr032296@LAP109053:/mnt/c/Users/abr032296$ rsync -azu /Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2/ ubuntu@10.104.35.171:/srv/shiny-server/DataScience/Senior/AbrCallAppTrending rsync: change_dir "/Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
请问我哪里操作出错了?
问题原因与解决方法
从命令行提示符abr032296@LAP109053:/mnt/c/Users/abr032296$能看出,你当前是在WSL(Windows子系统Linux)环境下执行命令,但你用了Windows/macOS原生的路径格式/Users/abr032296/Desktop/...,WSL无法识别这个路径。
具体修复步骤:
替换为WSL兼容路径
WSL把Windows的C盘挂载在/mnt/c目录下,所以你的目标目录对应的WSL路径是:/mnt/c/Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2/执行修正后的rsync命令
用正确路径重新运行命令:rsync -azu /mnt/c/Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2/ ubuntu@10.104.35.171:/srv/shiny-server/DataScience/Senior/AbrCallAppTrending先验证路径有效性
可以先通过cd命令进入目标目录,确认路径存在:cd /mnt/c/Users/abr032296/Desktop/Projects/ShinyAppHarold/Trended/PushToEc2/如果没有报错,再执行rsync命令即可。
另外,如果你的目录实际在macOS环境中,建议直接切换到macOS终端执行你最初写的命令,无需转换路径。
内容的提问来源于stack exchange,提问作者ATMA
相关产品推荐
相关产品推荐

