Skip to content
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

Forward HOME by default #2907

Merged
merged 1 commit into from Jan 31, 2023
Merged

Forward HOME by default #2907

merged 1 commit into from Jan 31, 2023

Conversation

gschaffner
Copy link
Contributor

@gschaffner gschaffner commented Jan 30, 2023

this ensures that os.path.expanduser and pathlib.Path.expanduser work by default inside a tox environment on non-Windows systems, including those without /etc/passwd.

fixes #2702.

this patch is analogous to #519.

Thanks for contribution

Please, make sure you address all the checklists (for details on how see
development documentation)!

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
    • i haven't done this because it is nontrivial to add tests that run on a system without /etc/passwd. the easiest way to get such a system is an OCI container, e.g.
      #!/usr/bin/env -S sh -c '< "$0" podman run --rm -i -v "$(dirname "$(realpath "$0")")":/tox-ro:ro nixery.dev/bash/coreutils/python311/git bash "$@"'
      
      set -o errexit -o errtrace -o nounset -o pipefail
      shopt -s inherit_errexit
      
      cd "$(mktemp -d)"
      python -m venv .venv &> /dev/null
      . .venv/bin/activate
      cp -r /tox-ro /tox
      
      set -o xtrace
      
      pip install -q /tox
      mkdir proj
      cd proj
      mkdir -p src/hello
      touch pyproject.toml src/hello/__init__.py
      printenv HOME
      cat /etc/passwd || true
      tox --colored yes
      but it's perhaps not worth the overhead to do that for this somewhat esoteric test.
  • added news fragment in docs/changelog folder
  • updated/extended the documentation
    • i haven't done this because the default pass_env on various platforms is not documented:

      tox/docs/config.rst

      Lines 279 to 281 in 079f839

      .. conf::
      :keys: pass_env, passenv
      :default: <empty list>

This ensures that os.path.expanduser works by default inside a tox
environment on non-Windows systems, including those without /etc/passwd.
@gschaffner
Copy link
Contributor Author

the pre-commit isort failure is unrelated to these changes; see #2908.

Comment on lines 235 to 240
env.extend(
[
"TMPDIR", # temporary file location
"HOME", # needed for `os.path.expanduser()`
],
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather pass this on all platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if https://superuser.com/a/607110 and https://stackoverflow.com/a/36392591 are correct, HOME isn't relevant on windows and USERPROFILE is the windows equivalent of it. USERPROFILE is already forwarded on windows:

tox/src/tox/tox_env/api.py

Lines 224 to 233 in 4408cff

if sys.platform == "win32": # pragma: win32 cover
env.extend(
[
"TEMP", # temporary file location
"TMP", # temporary file location
"USERPROFILE", # needed for `os.path.expanduser()`
"PATHEXT", # needed for discovering executables
"MSYSTEM", # controls paths printed format
],
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but for consistency what's the harm passing the HOME universally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none that i know of :)

do you want me to update this patch so it changes TMPDIR to be forwarded on windows too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that one.

@gschaffner gschaffner changed the title Forward HOME by default on non-Windows systems Forward HOME by default Jan 31, 2023
@gaborbernat gaborbernat merged commit f38cc3f into tox-dev:main Jan 31, 2023
descope bot added a commit to descope/django-descope that referenced this pull request Feb 14, 2023
This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
| [tox](https://togithub.com/tox-dev/tox)
([changelog](https://tox.wiki/en/latest/changelog.html)) | dev | patch |
`4.4.3` -> `4.4.4` | `4.4.5` |

---

### Release Notes

<details>
<summary>tox-dev/tox</summary>

### [`v4.4.4`](https://togithub.com/tox-dev/tox/releases/tag/4.4.4)

[Compare Source](https://togithub.com/tox-dev/tox/compare/4.4.3...4.4.4)

#### What's Changed

- Forward `HOME` by default by
[@&#8203;gschaffner](https://togithub.com/gschaffner) in
[tox-dev/tox#2907

**Full Changelog**: tox-dev/tox@4.4.3...4.4.4

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMDEuMCIsInVwZGF0ZWRJblZlciI6IjM0LjEwMS4wIn0=-->

Co-authored-by: descope[bot] <descope[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tox 4 breaks in CI/CD pipelines where user does not exist
3 participants