我有这样的fabfile.py:
from fabric.api import *
def deploy():
with prefix('source venv/bin/activate'):
local('pex -r <(cat requirements.txt) . -o app.pex')
当我运行$ fab deploy
时,我得到:
$ fab deploy
[localhost] local: pex -r <(cat requirements.txt) . -o app.pex
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `source venv/bin/activate && pex -r <(cat requirements.txt) . -o app.pex'
Fatal error: local() encountered an error (return code 1) while executing 'pex -r <(cat requirements.txt) . -o app.pex'
Aborting.
命令source venv/bin/activate && pex -r <(cat requirements.txt) . -o app.pex
在shell中运行正常。我是Fabric的新手。这里有什么问题?
答案 0 :(得分:2)
默认情况下fabric.operations.local()
function使用/bin/sh
作为运行命令的shell。这个基本的shell不支持/bin/bash
所有的语法。
如果您必须有权访问Bash shell语法,请设置shell='/bin/bash'
:
local('pex -r <(cat requirements.txt) . -o app.pex', shell='/bin/bash'))