Reputation: 3237
My fabric file:
def deploy():
code_path = 'mysite/public_html/mysite'
with cd(code_path):
with prefix("workon mysite"):
run('git pull')
run('supervisorctl -c ~/supervisord.conf restart ' + env.host_string)
I get the following error:
Aborting.
[myserv] out: /bin/bash: workon: command not found
Obviously workon command works when I do this manually (without fabric). I suspect /usr/local/bin/virtualenvwrapper.sh
is not being sourced (it normally gets run through .bash_profile).
What do I need to do to get workon
command working?
Upvotes: 3
Views: 4542
Reputation: 1350
I use pyenv with plugin pyenv-virtualenvwrapper. I had no success with workon, instead I use this (fabric 2.5):
with c.prefix('source /home/mirek/.virtualenvs/%s/bin/activate' % PROJECT):
with c.prefix('cd /home/mirek/dj/%s/%s' % (PROJECT, PROJECT)):
c.run('python manage.py ....')
Upvotes: 0
Reputation: 3646
you have to copy this virtualwrapper load code from .bashrc
to .bash_profile
file or if not exist create new .bash_profile
file and copy there.
code to copy::
export WORKON_HOME=/home/virtual
source /usr/local/bin/virtualenvwrapper.sh
this error happen because .bashrc
is only read by a shell that's both interactive and non-login. So in this case it is not interactive non-login shell, so it won't work. so we have to copy those code to .bash_profile
file.
Upvotes: 3
Reputation: 75558
Try modifying your prefix with:
with prefix(". /usr/local/bin/virtualenvwrapper.sh; workon mysite"):
Upvotes: 7