-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
__PYVENV_LAUNCHER__ being set creates unexpected problems for child Python instances #3576
Comments
Sorry, I bumped Enter by accident, editing the actual details into the issue now. |
In my digging to discover what was going on, I discovered that Python 3's |
This sounds like it's installation/configuration specific. What is |
However, if I bypass the asdf shims and invoke the Python binary directly, I get the same behaviour.
In zsh, without any modifications, I get the expected behaviour:
if I remove my
In zsh,
When created under zsh, the
If I delete
|
This doesn't sound like a general xonsh problem. It sounds like a potential quirk for how you installed and are launching xonsh. There's two fixes I see:
Without knowing more about when that variable gets used and why, I can't really say that something should be changed in xonsh itself. |
New versions of Python will unset it after interpreter startup so Python code doesn't see it; see python/cpython#9516. In the related bug report there is a comment describing the behaviour I'm seeing with creating virtualenvs, and miscellaneous other comments describing other issues it causes. I've tested it in the Python 3 that comes with macOS Catalina, as well as Python 3.7.7 and Python 3.8.2 installed via Homebrew; all three also have the environment variable set in an out-of-the-box Xonsh install, so it's not limited to pyenv.
So from a purely semantic perspective it's not a bug in Xonsh, but rather a CPython bug which is fixed upstream. But CPython versions with the bug will still be around for a while, and the vast majority of macOS users will be using the built-in Python or one installed from either Homebrew or Pyenv, which are all affected. Plus, the issues it causes are subtle and difficult to debug; I spent more time than I'd like wading through the internals of (I also had a number of other issues that I'm now suspecting might be related too, like CPython itself and Postgres both failing to build from source when run from Xonsh, but working fine from zsh or fish, to the point where I was considering giving up and going back to Fish.) For my own purposes, I've already added |
Wow, thanks for tracking this down @excitedleigh ! I'm always using I agree that we should unset it at startup. |
PRs welcome! |
A fix for this issue (which Not sure which version for 3.8 it was first added to, but I know through testing that 3.7.9 has the
Or you could do that, which would be functionally identical to the fix they added to cpython. |
Sweet. Thanks for the update @telamonian ! I'm going to close this out since it's been fixed upstream. |
On macOS, some older versions of Python leak __PYVENV_LAUNCHER__ into the interpreter's environment variables. Starting with Python 3.11, this causes problems with Python being able to start correctly when launched from the Python bootstrap template. This change introduces a workaround to prevent the problematic environment variable from leaking into launched subprocesses. I've verified this problem exists with the version of Python 3.7 included with Xcode, and there are reports of it also being an issue with the Python 3.8 included with Xcode. Later versions of Python have fixed this. Context: - https://issues.pigweed.dev/310293060 - xonsh/xonsh#3576 (comment) - pypa/virtualenv#1458
On macOS, some older versions of Python leak __PYVENV_LAUNCHER__ into the interpreter's environment variables. Starting with Python 3.11, this causes problems with Python being able to start correctly when launched from the Python bootstrap template. This change introduces a workaround to prevent the problematic environment variable from leaking into launched subprocesses. I've verified this problem exists with the version of Python 3.7 included with Xcode, and there are reports of it also being an issue with the Python 3.8 included with Xcode. Later versions of Python have fixed this. Context: - https://issues.pigweed.dev/310293060 - xonsh/xonsh#3576 (comment) - pypa/virtualenv#1458
xonfig
Expected Behavior
When I run
python -m venv
from within Xonsh, the virtualenv created should be based on the Python I'm invoking, not the Python that Xonsh is running in.Current Behavior
The virtualenv created is based on the Python that Xonsh is running in.
If I put
del $__PYENV_LAUNCHER__
in my.xonshrc
, everything works as expected.I think this may also be the cause of issues I've been having getting Pyenv to compile Python, but I've yet to test this.
Steps to Reproduce
python -m venv
to make a virtualenv with the latter.The text was updated successfully, but these errors were encountered: