Vercel部署时使用rsync提示command not found的解决方法咨询
Vercel部署时使用rsync提示command not found的解决方法咨询
我有一个Python脚本,作为静态站点项目yarn build的一部分运行,部署到Vercel。这个脚本用rsync做文件复制,通过Python里的os.system调用rsync:
os.system(f"rsync -a {full_path} dest_path")
本地运行完全没问题,但部署到Vercel时就报错:
sh: line 1: rsync: command not found
我还尝试了几种其他方法:
- 使用
subprocess.run通过npx来执行命令:
得到的Vercel构建错误:subprocess.run(["npx", "rsync", "-a", full_path, dest_path], check=True)npm error could not determine executable to run
- 尝试在package.json的开发依赖里添加rsync后重试,也没有解决问题
- 最后还试过先获取rsync路径再执行:
得到的Vercel构建错误:rsync_path = subprocess.check_output(["which", "rsync"]).decode("utf-8").strip() subprocess.run([rsync_path, "-a", full_path, dest_path], check=True)error Command failed with exit code 1.
想请教下有没有简单的方法能在Vercel部署过程中使用rsync?部署机器上到底有没有rsync?如果没有的话,该怎么配置才能用上rsync?
备注:内容来源于stack exchange,提问作者Blargian




