Reputation: 12187
I just can't figure out why this is happening...
in my fabric file I have this...
def func():
local("source ../venv/bin/activate")
It is returning 127 on the source command and I am not sure why, when i try to run source in my terminal manually it works. When I try a different command in fabric, like...
local("echo 'foo'")
it also works. Why would source be causing problems? I can't see any reason why this would be happening.
Upvotes: 2
Views: 636
Reputation: 4137
source
is unknown by sh
. If you want to run a command in the context of a virtual environment, use Fabric's context managers and run the activate
binary without source. I've adapted from this answer.
from __future__ import with_statement
from fabric.api import *
from contextlib import contextmanager as _contextmanager
env.activate = '. ./.env/bin/activate'
@_contextmanager
def virtualenv():
with prefix(env.activate):
yield
def deploy():
with virtualenv():
local('echo hello world!')
Upvotes: 4