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

venv.create() fails when sys._base_executable is empty #96861

Closed
meeuw opened this issue Sep 16, 2022 · 2 comments
Closed

venv.create() fails when sys._base_executable is empty #96861

meeuw opened this issue Sep 16, 2022 · 2 comments
Assignees

Comments

@meeuw
Copy link

meeuw commented Sep 16, 2022

Bug report

venv.create() fails when sys._base_executable is empty.

This happens when Python cannot determine the base_executable when it's started without a full path and PATH is empty:

$ env -i python
Python 3.10.6 (main, Aug  2 2022, 00:00:00) [GCC 12.1.1 20220507 (Red Hat 12.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys ; print(sys._base_executable)

>>> 
$ env -i python -mvenv /tmp/dmtest
Unable to symlink '' to '/tmp/dmtest/bin/meeuw'
Error: [Errno 2] No such file or directory: ''

Your environment

  • CPython versions tested on: 3.10.6
  • Operating system and architecture: linux / x86_64

Would it be possible to raise an exception when sys._base_executable is empty with a sane error message?

Related to: python-poetry/install.python-poetry.org#43

@meeuw meeuw added the type-bug An unexpected behavior, bug, or error label Sep 16, 2022
@vsajip
Copy link
Member

vsajip commented Sep 17, 2022

This isn't a bug in venv. If you do env -i python, then sys.executable is set to the empty string, so lots of things would break.

@vsajip vsajip added pending The issue will be closed if no feedback is provided and removed type-bug An unexpected behavior, bug, or error labels Sep 17, 2022
@meeuw
Copy link
Author

meeuw commented Sep 17, 2022

I'm not so sure about that, the documentation describes that sys.executable can be empty:

If Python is unable to retrieve the real path to its executable, sys.executable will be an empty string or None.

I think it makes sense for venv to error out with a proper error message. For example start python using a full path or set a PATH where python can be found.

@vsajip vsajip removed the pending The issue will be closed if no feedback is provided label Sep 17, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 18, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 18, 2022
vsajip added a commit that referenced this issue Sep 18, 2022
…GH-96887) (GH-96918)

(cherry picked from commit 2cd70ff)

Co-authored-by: Vinay Sajip <[email protected]>

Co-authored-by: Vinay Sajip <[email protected]>
@vsajip vsajip closed this as completed Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants