Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why can't upstart run 'source bin/activate'?

upstart won't activate my virtualenv for some reason.

This is how I run it

script     # My startup script, plain old shell scripting here.     cd path/to/env     source bin/activate     .... end script 

the virtualenv runs fine when started manually

Why does this not work?

like image 225
Calum Avatar asked Feb 11 '13 23:02

Calum


People also ask

What is source bin activate?

bin/activate is the bash script being run. One other detail of source will be important. source runs the file provided in your current shell, not in a subshell. Thus it keeps the variables it creates or modifies around after the file is done executing.

How do I know if my virtual environment is activated?

Note: Before installing a package, look for the name of your virtual environment within parentheses just before your command prompt. In the example above, the name of the environment is venv . If the name shows up, then you know that your virtual environment is active, and you can install your external dependencies.


2 Answers

So I've worked it out, for some reason upstart doesn't like using 'source' so I changed the line from:

source bin/activate 

to

. bin/activate 

and that works, don't know why though, so would be interested if someone could explain this

like image 64
Calum Avatar answered Sep 24 '22 08:09

Calum


source is a bash built-in command but only a posix "special" command.

Upstart runs sh -e when executing the script sections.

sh shell doesn't understand source, only .

like image 29
Jeffrey Martinez Avatar answered Sep 22 '22 08:09

Jeffrey Martinez