-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Using venv creator creates broken environment in Ubuntu 22.04 #2340
Comments
As a follow up question I wanted to ask: |
Can confirm, I'm having the same issue with PopOS 22.04 |
Posting a docker image that reproduces this would be helpful here. |
I am not an expert with Docker, but I could not reproduce this bug in the ubuntu:22.04 image. However, the Ubuntu Docker image is much more slim and includes way fewer debs than the Ubuntu Desktop ISO and of course no Gnome or similar. There could easily be some configuration in the Desktop ISO that is not included in the Docker image. What I tried: FROM ubuntu:22.04
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
python3 \
python3-pip \
python3-venv \
python3-virtualenv \
&& apt-get clean
CMD ["/usr/bin/bash"] putting the above into a Dockerfile in a directy, then building and running it with: docker build --tag=virtualenvtest .
docker run -it virtualenvtest
python3 -c "import sysconfig; print(sysconfig.get_default_scheme())"
virtualenv --version
virtualenv --creator=venv myenv -vvv --with-traceback
ls myenv/bin
ls myenv/local/bin # says there is no myenv/local directory Again, this does not reproduce the bug. We do have someone with the same problem here so it does seem to not only be on my system. |
Similar issue manifested for me as well, after manual upgrade from 21.04 to 22.04, so it might be related to the upgrade process. For me, the result is that I get a complete random list of files/dirs inside my virtualenv dir. Sometimes it's like this: user@host:~$ ls -a venv
. .. .gitignore lib local pyvenv.cfg Sometimes, there is a bin folder with just the symlinks ... user@host:~$ ls venv/bin/
python python3 python3.10 I am using the latest available virtualenv from |
I just wanted to add that my 22.04 installation was a fresh install, so it might not be directly related to the upgrade process but some settings or config from 22.04 in general. |
I wanted to add. I initially upgraded from PopOS 21.10 to 22.04 and that's when things fell apart. My django project wouldn't run at all, couldn't update pipenv packages so I recreated my interpreter and it failed. I had other issues since the upgrade not related to virtualenv so I reinstall the OS. I did a refresh, so the OS was reinstalled, which keeps your home directory but I lost all of my apps. Issue with virtual env was there but the other issues and errors went away. I'm getting the /bin and /lib folders inside a local folder when I run virtualenv manually. My PyCharm IDE fails to create the env as well. I can install the OS on a virtual machine and see if I get the same results. |
I installed PopOS 22.04 on a virtual machine and did two tests, the first was with no system updates after install and the other was after installing system updates. Both test created the lib and bin in .venv/. sudo apt-get install python3-pip On my machine, I ran the same commands and I get a lib and local folder. Inside the local I have lib and bin. I'm not sure what I can do to help. |
I believe that if we knew why/when |
PR addressing the underlying issue is welcome. |
if we are to attempt a fix, we need a bit of guidance as to where should we start? |
Finding out what is happening and how to fix it is like 80% of the work needed here 😅 so what questions do you have? |
Obviously it is! I would like to know where the folder path is decided in the code, where the local/bin is created. |
Will be in the creator code here somewhere https://github.com/pypa/virtualenv/blob/main/src/virtualenv/create/via_global_ref/builtin/via_global_self_do.py that likely uses the information feeded by https://github.com/pypa/virtualenv/blob/main/src/virtualenv/discovery/py_info.py. Per the logs above CPython3Posix is the creator, so will be somewhere in its inheritance chain. |
I ended up rebuilding my machine, still hit the issue on a clean
install.
To work around the issue, I run this and recreate the venv folder in
the project. I use pipenv for my project. I think Debian made a change
and this export reverts back to the previous setting.
export SETUPTOOLS_USE_DISTUTILS=stdlib
…On Mon, 2022-07-18 at 13:36 -0700, Bernát Gábor wrote:
Will be in the creator code here somewhere
https://github.com/pypa/virtualenv/blob/main/src/virtualenv/create/vi
a_global_ref/builtin/via_global_self_do.py that likely uses the
information feeded by
https://github.com/pypa/virtualenv/blob/main/src/virtualenv/discovery
/py_info.py
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID:
***@***.***>
|
I could create a Dockerfile to reproduce the issue. It requires setuptools>=60.0.0
It prints
There are both
|
@rkucsora do you see the same behaviour if you use the builtin creator instead of the venv one? |
Not the same, in that case there is only a
|
This project is only responsible of the builtin creator. The venv creator is managed by debian so for that you're looking at filling a bug for that projects tracker. |
This works-around this virtualenv bug: pypa/virtualenv#2340 This issue came to our attention via: #104 Signed-off-by: Jake Garver <[email protected]> Reviewed-by: Jeff Brasen <[email protected]> Reviewed-by: Ashish Singhal <[email protected]> Reviewed-by: Jeshua Smith <[email protected]>
Issue
Using
venv
as creator -virtualenv --creator=venv myenv
- creates a broken virtual environment on Ubuntu 22.04.It produces two different activate scripts, one in
myenv/bin
and one inmyenv/local/bin
.Depending on which one I activate, either it uses the wrong Python Interpreter or the wrong Pip:
I found this post regarding a change in the
sysconfig.get_default_scheme()
for Ubuntu 22.04, which might be the reason whyvirtualenv
tries to install intomyenv/local/bin
instead if justmyenv/bin
.Environment
Provide at least:
pip list
of the host python wherevirtualenv
is installed:Output of the virtual environment creation
virtualenv --creator=venv myenv -vvv --with-traceback
The text was updated successfully, but these errors were encountered: