server.shell does not support env?
See original GitHub issueI have this code:
env = dict(EMAIL=host.data.email)
cmd = f"docker stack deploy --compose-file docker-compose.yml {app}"
server.shell(name=f'Deploying stack {app}',
commands=cmd,
chdir=app_dir,
env=env,
)
but this gives a confusing error:
--> Starting operation: tasks/setup_traefik.py | Deploying stack traefik
[testbox.tothemax.nl] env: ‘cd’: No such file or directory
[testbox.tothemax.nl] Error
--> pyinfra error: No hosts remaining!
Removing env=env makes the error go away (but obviously does not transfer the env vars.)
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Shell variable support in server.env · Issue #14901 - GitHub
Sourcing the server.env would actually break support for having an odd number of single quotes in a value. The solution must not require...
Read more >How To Read and Set Environmental and Shell Variables on ...
In this guide, we will discuss how to interact with the environment and read or set environmental and shell variables interactively and through ......
Read more >How to Set, List and Manage Linux Environment Variables
Shell variables are not the same as environment variables. Shell variables only apply to the current shell, not any child processes.
Read more >162018 – [ssh][shells] environment getting and setting are not ...
I try to use a remoteshell to execute a command where I set a specific environment. The environment I specify does not get...
Read more >Why does an SSH remote command get fewer environment ...
Great answer, this was exactly the problem, the needed environment variables resided in /etc/bashrc, which is not sourced in non interactive mode. Moving...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You are right (of course). Not trusting bash, here is a python equivalent:
Thanks.
@mjmare this is due to the way bash/shell parses the command; the envvar is being set correctly but the
$hello
is evaluated beforehand; if you runprintenv
you’ll see the envvar exists:To echo the envvar you need to wrap the command w/
sh
: