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

Comments

Projects
3 participants
@AndreLouisCaron
Contributor

AndreLouisCaron commented May 18, 2017

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

This comment has been minimized.

Contributor

AndreLouisCaron commented May 18, 2017

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

This comment has been minimized.

yan12125 commented May 19, 2017

$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

This comment has been minimized.

Contributor

AndreLouisCaron commented May 19, 2017

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

This comment has been minimized.

Member

obestwalter commented Jul 2, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment