New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fabric does not pass the environment to a local shell like Invoke does #1744
Comments
I discovered the description of this behavior. However, it makes no sense when running the command locally |
This is typical for running commands on remote systems:
One could try to pass through all environment variables by collecting the whole local environment and setting them on the other side, but there are quite a number which would need to be ignored because they would conflict with the appropriate value for the remote system, like |
Note that I am talking solely about local tasks. I have even discovered a TODO comment that confirms that passing environment should be on by default for local commands. |
ah, I see, makes sense |
@justinas I ended up using run from invoke for local tasks, I import it like this: from invoke import run as local
@task
def test(c):
local('ls') |
This is a facet of #1752 - the intent is for |
Thanks for the response! |
I just bumped into the same issue and I just wanted to note that it's not just the local environment that gets discarded. Maybe you are already aware of this bug also. To clarify, this didn't work for me: @task
def test(c):
c.run('echo $ENV', env={'ENV': 'production'}) # no output For the time being I found this workaround (not very clean) that I can use: @task
def test(c):
with c.prefix('ENV=production'):
c.run('echo $ENV') # prints "production" |
Yes, aware of that, thanks! |
You can say |
PS: I need to set the environment for remote tasks, not local. |
Yea I meant |
I just ran into this as well. I was doing Edit: I see according to the docs:
It was just a bit confusing to me since I was trying to run a local command. |
The issue is still there when running local command. @bitprophet |
Consider this task definition, saved as both
fabfile.py
andtasks.py
:fab make
outputs:inv make
outputs:I initially found this when trying to use fpm which checks the
PATH
variable to check that the executables it requires to function exist:This works with invoke, but not with fab.
The text was updated successfully, but these errors were encountered: