From ad0dcaeb9bf1e12b5c1e74ac9e36d5b68d350d78 Mon Sep 17 00:00:00 2001 From: Ganden Schaffner Date: Sun, 29 Jan 2023 00:00:00 -0800 Subject: [PATCH] Forward HOME by default This ensures that os.path.expanduser works by default inside a tox environment on non-Windows systems, including those without /etc/passwd. --- docs/changelog/2702.bugfix.rst | 1 + src/tox/tox_env/api.py | 1 + tests/session/cmd/test_show_config.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/2702.bugfix.rst diff --git a/docs/changelog/2702.bugfix.rst b/docs/changelog/2702.bugfix.rst new file mode 100644 index 000000000..7f3e64eed --- /dev/null +++ b/docs/changelog/2702.bugfix.rst @@ -0,0 +1 @@ +Forward ``HOME`` by default - by :user:`gschaffner`. diff --git a/src/tox/tox_env/api.py b/src/tox/tox_env/api.py index 1542a8fc6..fcfc9e4b8 100644 --- a/src/tox/tox_env/api.py +++ b/src/tox/tox_env/api.py @@ -218,6 +218,7 @@ def _default_pass_env(self) -> list[str]: "CPPFLAGS", # C++ compiler flags "LD_LIBRARY_PATH", # location of libs "LDFLAGS", # linker flags + "HOME", # needed for `os.path.expanduser()` on non-Windows systems ] if sys.stdout.isatty(): # if we're on a interactive shell pass on the TERM env.append("TERM") diff --git a/tests/session/cmd/test_show_config.py b/tests/session/cmd/test_show_config.py index 9ef9f3007..46a042465 100644 --- a/tests/session/cmd/test_show_config.py +++ b/tests/session/cmd/test_show_config.py @@ -117,7 +117,7 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty: expected = ( ["CC", "CCSHARED", "CFLAGS"] + (["COMSPEC"] if is_win else []) - + ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "LANG", "LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"] + + ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "HOME", "LANG", "LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"] + (["MSYSTEM", "NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else []) + ["PIP_*", "PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"] + (["PROCESSOR_ARCHITECTURE"] if is_win else [])