Sequoia 15.4更新后AppleScript调用rsync失败求助
问题描述
此前正常运行的AppleScript在升级到Sequoia系统后失效,测试路径赋值语句正常,但执行rsync命令时提示源路径/Volumes/Media Main/不存在。rsync文件大小较15.3版本有变化,但版本号显示一致,无法定位问题。
脚本代码
set source to "/Volumes/Media Main/" set destFolder to "/Volumes/Media Backup" set userPath to "/Volumes/Macintosh SSD 1TB/Users/bill/" do shell script "/Volumes/Macintosh\\ HD/usr/bin/rsync -av --delete --exclude=.* -i -log-file=" & quoted form of (userPath & "Desktop/AppleScriptLog/MediaBackup.txt") & space & (quoted form of source) & space & (quoted form of destFolder) tell application "TextEdit" to open POSIX file (userPath & "Documents/Done.txt")
错误信息
Result: error "rsync(9167): error: 2024/12/12 15:15:15 [32315] .d..t.... Media Main/: stat: No such file or directory rsync(9167): warning: child 9168 exited with status 23" number 23
解决方案
修正rsync执行路径
Sequoia可能调整了启动盘挂载路径,脚本中硬编码的/Volumes/Macintosh\\ HD/usr/bin/rsync大概率失效。直接使用系统默认路径/usr/bin/rsync替换,避免依赖旧的卷名路径。验证挂载卷的实际状态
打开终端执行ls /Volumes/,确认Media Main、Media Backup卷是否存在,且路径拼写(包括空格、大小写)完全匹配。系统升级后可能出现卷挂载异常,导致路径无法被rsync识别。添加rsync调试日志
在rsync命令中加入--verbose --debug=ALL参数,获取详细的路径解析日志,排查是否存在转义或路径解析错误:do shell script "/usr/bin/rsync -av --delete --exclude=.* -i --verbose --debug=ALL -log-file=" & quoted form of (userPath & "Desktop/AppleScriptLog/MediaBackup.txt") & space & (quoted form of source) & space & (quoted form of destFolder)检查应用权限
确保运行该AppleScript的应用(如Script Editor、Automator)已在「系统设置-隐私与安全性-完全磁盘访问」中获得授权。Sequoia对磁盘访问权限管控更严格,权限不足会导致rsync无法读取卷内容。替换为第三方rsync版本
若系统自带rsync存在兼容性问题,可通过Homebrew安装最新版:brew install rsync然后在脚本中使用对应路径(Intel芯片用
/usr/local/bin/rsync,Apple芯片用/opt/homebrew/bin/rsync)替换系统rsync。
内容的提问来源于stack exchange,提问作者Bill

