我正在尝试在远程服务器上运行一个已安装在我的主目录中的命令。该命令已经添加到了我的.bash_profile的$PATH中。当通过正常的ssh会话远程登录时,我能够使用它,但是Fabric似乎没有引入我的$PATH。因此,我尝试使用Fabric的path上下文管理器将其添加到我的$PATH中,如下所示:
def test_path():
print('My env.path setting: %(path)s' % env)
with path('/path/to/sources/drush'):
run('echo $PATH')
run('drush')
Fabric的响应如下:
Executing task 'test_path'
My env.path setting:
run: echo $PATH
out: /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
out:
run: echo $PATH
out: /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/path/to/sources/drush
out:
run: drush
out: /bin/bash: drush: command not found
out:
Fatal error: run() received nonzero return code 127 while executing!
Requested: drush
Executed: /bin/bash -l -c "export PATH=\"\$PATH:\"/path/to/sources/drush\" \" && drush"
Aborting.
Thanks for looking...
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/path/to/sources/drush
。 - user981023print('My env.path setting: %(path)s' % env)
,这表明env.path为空。 - user981023