简体   繁体   中英

Fabric: syntax error near unexpected token '('

I have such fabfile.py:

from fabric.api import *

def deploy():
    with prefix('source venv/bin/activate'):
        local('pex -r <(cat requirements.txt) . -o app.pex')

when I run $ fab deploy I get:

$ 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.

The command source venv/bin/activate && pex -r <(cat requirements.txt) . -o app.pex source venv/bin/activate && pex -r <(cat requirements.txt) . -o app.pex runs OK in shell. I'm new to Fabric. What's wrong here?

The fabric.operations.local() function by default uses /bin/sh as the shell to run the command. This basic shell doesn't support all of the syntax that /bin/bash would.

Set shell='/bin/bash' if you must have access to Bash shell syntax:

local('pex -r <(cat requirements.txt) . -o app.pex', shell='/bin/bash'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM