Fabric + DigitalOcean:不可见环境变量? [英] Fabric + DigitalOcean: unvisible ENVIRONMENT VARIABLE?
问题描述
export CONFIG = / path / to / conf
当我在远程控制台上执行
>>> echo $ CONFIG
>>> / path / to / conf#result,因为它应该是
但是在 fabfile 我有一个函数
def show():
run(echo $ CONFIG)
它打印一个空字符串。为什么?
提前感谢
不应该是这样,默认情况下Fabric使用 我也无法再现您的问题: 所以我的猜测是你更改了 I have server on DigitalOcean and I use fabric for deploying my code. And my code is dependent on environment variables (flask config). I've faced one strange trouble today: on server in /root/.bashrc I've added next line And when I executing on remote console But in fabfile I have a function And it prints an empty string. WHY?
Thanks in advance! This shouldn't be the case, as by default Fabric uses the I am also not able to reproduce your issue: So my guess is that you've changed the 这篇关于Fabric + DigitalOcean:不可见环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! -l </ code>标志应该是
使bash的行为好像已被调用为登录shell(请参阅下面的INVOCATION)。
/ p>
$ fab -H home test_bash
[home]执行任务'test_bash'
[home] run:grep FOO $ HOME / .bashrc
[home] out:export FOO =BAR
[home] out:
[home] run:echo $ FOO
[home] out:BAR
[home] out:
env.shell
,或者你'不是连接作为根
用户,你正在设置这个bash导出。 (请注意,在Fabric使用中 run()
与 sudo()
不同)export CONFIG=/path/to/conf
>>> echo $CONFIG
>>> /path/to/conf # result, as it should be
def show():
run("echo $CONFIG")
-l
flag which is supposed to Make bash act as if it had been invoked as a login shell (see INVOCATION below).
$ fab -H home test_bash
[home] Executing task 'test_bash'
[home] run: grep FOO $HOME/.bashrc
[home] out: export FOO="BAR"
[home] out:
[home] run: echo $FOO
[home] out: BAR
[home] out:
env.shell
, or that you're not connecting as the root
user which is where you're setting this bash export. (Note that run()
isn't the same a sudo()
in Fabric usage)