wntrblm/nox

`include_outer_env=False` will include outer_env when `env` is not set

Opened this issue · 3 comments

Current Behavior

On include_outer_env=False, all outer environment variable will be used, when env is not set or None.

Expected Behavior

When include_outer_env=False, no environment variables should be set. Also when no env is set.
Current workaround is env={}

Steps To Reproduce

import nox

@nox.session
def env(session: Session):
    session.run("printenv", include_outer_env=False)
    session.run("printenv", include_outer_env=False, env={})

Environment

- OS: MacOS 15
- Python: 3.12.7
- Nox: 2024.4.15

Anything else?

No response

Actually, I think there's a second bug. I believe VIRTUAL_ENV and CONDA_PREFIX don't get set if you use this option, as well.

tox1 do a lot of magic to pass the correct values.

Should nox stay this clean way?

Maybe some more configurable?

include_outer_env: Literal["all", "recommended", "none"]

while recommended will pass a similar list of environment variables like in tox.

e.g. on my setup I need to set HOME again, otherwise it wouldn't find my .netrc with the credentials for a private pypi repository.

Footnotes

  1. https://github.com/tox-dev/tox/blob/08f2ac55d67b1ca91e56e61fb09d6f7d7034ef2a/src/tox/tox_env/api.py#L204

This is a separate issue (nox isn't even setting its own variables when include_outer_env is false, like VIRTUAL_ENV). But not a bad (separate) idea.