It has a deploy.sh script, in which there is a line that should put packages locally in a virtual environment:

 echo -e "\nInstalling requirements..." sh -c "pip install -r requirements.txt" 

The script is started by the sudo ./deploy.sh , therefore, the dependency installation command is executed as

 sudo pip install -r requirements.txt 

and packages are installed globally, not locally for the current project.

How to make the command run without sudo ?

Refinement - the script contains commands that require superuser rights

  • 2
    logical answer: run the script without using the sudo program. - aleksandr barakin
  • @alexanderbarakin it contains commands that require superuser rights. clarified in the question - while1pass
  • break the script into two. or use the sudo program where necessary. - aleksandr barakin
  • 2
    Why not write sudo where necessary inside deploy.sh itself? - andreymal
  • one
    First, you can plug in the verification that the script was not launched through sudo, and secondly, there is nothing to give strangers access to such things :) - andreymal

1 answer 1

You can run a specific command from the user who ran the script with sudo. It is available through the $SUDO_USER environment variable. First you need to activate the environment, then install dependencies in it.

 sudo -u $SUDO_USER ./env/bin/activate && pip install -r requirements.txt 

Source: https://stackoverflow.com/q/41366023/2790048