Skip to content

No way to specify remote environment variables #1826

Description

@max-arnold
from fabric import task

cmd = '''python3 -c "import os; print(os.environ.get('ENV'))"'''

@task
def test_env(ctx):
    ctx.run(cmd, replace_env=False, echo=True, env={'ENV': 'production'})

@task
def test_prefix(ctx):
    with ctx.prefix('ENV=production'):
        ctx.run(cmd, replace_env=False, echo=True)

First task prints None because the default sshd install has AcceptEnv LANG LC_* and nothing else (see #1744 (comment)):

% fab -H example.com test-env

python3 -c "import os; print(os.environ.get('ENV'))"
None

Second one fails due to && (although it probably used to work, see #1744 (comment)):

% fab -H example.com test-prefix

ENV=production && python3 -c "import os; print(os.environ.get('ENV'))"
None

The value of replace_env flag does not matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions