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

USERPROFILE is not automatically forwarded on Windows #518

Closed
AndreLouisCaron opened this issue May 18, 2017 · 4 comments
Closed

USERPROFILE is not automatically forwarded on Windows #518

AndreLouisCaron opened this issue May 18, 2017 · 4 comments

Comments

@AndreLouisCaron
Copy link

Hi there!

Given the following tox.ini:

[tox]
skipsdist = true

[testenv]
commands =
  python -c 'import os.path; print(os.path.expanduser("~"))'

Then, on Windows, this will incorrectly print ~.

If you add a passenv section to forward USERPROFILE, then it gives the right output:

[tox]
skipsdist = true

[testenv]
passenv =
  USERPROFILE
commands =
  python -c 'import os.path; print(os.path.expanduser("~"))'

This prints C:\Users\... as you would expect.

If I'm not mistaken, I believe HOME is forwarded by default on other systems, I would assume USERPROFILE should also be forwarded by default on Windows.

I'll gladly work on a patch if you're willing to accept such a contribution!

@AndreLouisCaron
Copy link
Author

Note that, apart from os.path.expanduser(), I also need to pass this when running pip-compile inside a virtual environment when using a private package index (such as DevPI); it seems like pip relies on this variable to find pip.ini.

@yan12125
Copy link

$HOME is not automatically forwarded on Unix-like systems (Linux, Mac, ...), either. I don't know the design philosophy of tox, though. I was bitten by this when trying to use homebrew on Mac.

@AndreLouisCaron
Copy link
Author

IIRC, Tox 1.x used to forward the entire environment by default, but this created issues with reproducing builds (env-dependent builds are really annoying). Then, Tox 2.0 changed this to forward as few things as possible. I remember the port from Tox 1.9 to 2.0+ because I debugged a lot of these hidden dependencies on environment variables (see PR #520 for another example).

It makes sense from a testing standpoint, but (in addition to testing) I've been using Tox more and more as a one-liner for "find Python, install deps without affecting the system and run this command"-style automation. In that context, having random stdlib stuff breaking for obscure reasons is less fun :-/

@obestwalter
Copy link
Member

I agree that these hidden dependencies should be taken into account and hopefully we caught all of them by now, but I opened an issue asking for help to take a closer look: #539.

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants