[Python] command not found when trying to use rsync on Vercel

Discussão em 'Python' iniciado por Stack, Janeiro 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python script which runs as part of yarn build for my static-site project deployed to Vercel. The script uses rsync to do some file copying, using os.system to make the call to rsync from within the python script: os.system(f"rsync -a {full_path} dest_path"). This works great locally, however when I try to deploy to Vercel I get the error:

    sh: line 1: rsync: command not found


    I tried a few other approaches as well:

    • using subprocess.run(["npx", "rsync", "-a", full_path, dest_path], check=True) to try get npx to run the command.

    Vercel build error:

    npm error could not determine executable to run


    • Tried adding rsync to my developer dependencies in package.json and retrying.


    • Finally I also tried using rsync_path = subprocess.check_output(["which", "rsync"]).decode("utf-8").strip() subprocess.run([rsync_path, "-a", full_path, dest_path], check=True)

    Vercel build error:

    error Command failed with exit code 1.


    Is there a simple way for me to use rsync during my Vercel deployment? Does it even exist on the deployment machine? If not how can I set it up to use rsync?

    Continue reading...

Compartilhe esta Página