-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Pipenv searches virtual environment's python binary in wrong path #5109
Comments
same here. many thanks @elegos for your detailed workaround. it works for me also. system info:
sample of original failure:
distilled @elegos workaround:
edit: formatting |
Thank you for the workaround @elegos - This resolved the same issue on my system, which occurred after recently applying Fedora updates.
|
Thanks @elegos the workaround also worked for me, this problem started after I update to fedora 36.
|
@RonaldTheodoro @garethheath @undefx and @elegos -- Do you think this PR would fix the issue and eliminate the need for the workaround? #5096 |
Hello @matteius yes, it should exactly do the trick we need :) |
Hi @elegos , I've already deployed the fix for this (#5096) in Fedora rawhide and we're testing it there. The RPM might be installable on F36 too if you'd like to help us test it: https://koji.fedoraproject.org/koji/buildinfo?buildID=1965245 |
Do you expect this to land in F36 later on? (It's one of the issues holding me back from upgrading currently. :)). |
+1 We use this in CI, so if this is not going into an F36 rpm update (or at least a pypi update) soon, we will have to implement a workaround in CI, which I would prefer not to do if we can help it. |
FWIW it has been merged into master branch of pipenv and I plan to do a pipenv release at some point soon, like say in the first week of June, probably. Trying to see what else we can get into that release that would be fixing an issue as well. |
We have an older version of pipenv packaged in F36 which according to my testing does not suffer from this issue. I suspect you're using a newer version of pipenv installed from PyPI and thus getting the error, am I correct? If so, a new release of pipenv will fix that. |
I uninstalled pipenv from pypi using EDIT: You are correct, I probably still had a pipenv leftover somehow in my VM at work. |
The version in F36 is 2021.5.29, which is vulnerable to this CVE, so we are in an awkward position until a new release (at least to pypi, ideally also to F36) - either use a version with a known CVE, or have a broken version - the rawhide rpm in CI is not really something we can use, for multiple reason. |
We have fixed this CVE in all active Fedoras (rawhide, 36-34) with a downstream patch: https://bugzilla.redhat.com/show_bug.cgi?id=2039831 |
Perhaps we are doing something wrong then? We are running 'pipenv check -v', and it still reports this CVE, using the rpm version referenced above. |
Hmmm, I'm not really sure about that. My guess would be |
I would be happy to, but looking at the CVE, I don't see a reproducer to try, am I looking in the wrong place? If it is helpful, I see the portion of
|
Yes I believe that is correct. What version of pipenev are you reporting on @jguiditta |
The reproducer is in the pipenv test suite, here: https://github.com/pypa/pipenv/pull/4899/files#diff-a28b281ee0902c932527e269c585ac109bdd98aa5ceebe05ca97a10a5a432651 We've backported the fix and the tests and all of them pass on the Fedora, so we believe the CVE to be fixed on all Fedoras. |
I'll make some adjustments to our job and see what else I can find out, including the answer to your question on version, though it should be the one matching the rpm mentioned earlier in this discussion. I don't see how there would be a prexisting pipenv in the virtualenv, since this is a fresh container created in CI each time, but I will do some more poking. @torsava thank you for the reproducer, I will incorporate that in my tests as well, and hopefully have some more useful information tomorrow. Thank you both for the replies! |
OK, bit of a follow-up. The net is that I think using pipenv to check for CVEs will not work as expected with a distro-installed version of pipenv that has backported fixes. I did a bit of testing, making sure I ONLY had the pipenv from fedora 36 installed. I did check the above questions first, and there is indeed NO pipenv installed into the project (it is only used TO install the project). Second, version:
The new bit is, on re-reading the pipenv --help output, I noticed it uses pyup to check for CVE, not any local information, aside from matching version in the Pipfile:
Since pyup is likely not looking at distro-specific backports, this is likely why, even though we have the CVE fix in fedora 36, the check thinks we do not. I think the net is, it we want to use 'pipenv check', we need to use a version of pipenv for a pip install to get reliable results. If that is off the rails, let me know. Otherwise, thank you for your responses/help, and I will look forward to the next release on pypi. |
@jguiditta I don't quite understand -- We haven't fixed a CVE in recent releases so whatever was backported was a fix from a while ago -- if PyUp is saying there is an issue with |
However for an Ubuntu 22.04 environment (same python 3.10.x version) @elegos 's workaround does not work :( |
@kissifrot did you try the main branch of pipenv? The fix hasn't been released to pypi yet, but it would be good if someone could verify the main branch fixes this issue ahead of a new release. |
I'll try pipenv git tonight or tomorrow on F36. |
I am not sure why we can't get the new version(s) in released fedora, but if you look at the list of builds for the package [here]https://koji.fedoraproject.org/koji/packageinfo?packageID=27010l), you can see that is the newest version, aside from rawhide, which is for testing, and not viable for our CI environment. I understand that the release pipenv shows does not contain the cve fix in question, though the fix was backported (again, not sure on reason in this case, it may just be some rules fedora gas around how much you can update a package in a given release). What I was trying to point out was that I now understand why pipenv check fails, even though the fix has been backported (because it is checking pyup against the stated version, which obviously did not contain the fix). Ideally, we would just get new releases in the fedora package management system that match upstream, but the release process there may just not allow it. Also, to clarify, running from pypi is a viable alternative (though it would be nice to be able to use the dnf version), we will just need to wait until the current issue in this thread is released, as building from source in CI is not really something we can do. |
Thanks @mbothorel -- I am going to try to get a release out today then. |
|
@matteius Thank you very much! |
I didn't find the time to test. Sorry about that. Regardless, I tested the released version now and it works perfectly. Thanks all! |
Hello,
I'm having trouble using Pipenv lately. In particular, after I updated my OS (Fedora 36), pipenv during the
install
command tries to search the python binary inside{local_virtualenv}/local/bin/python
, while the symlink to python is in{local_virtualenv}/bin/python
. I tried to remove and reinstall the virtual environment (pipenv --rm
andpipenv install
), but the problem persists.Application versions
Pipenv install
pipenv shell
andecho $PATH
:As you can see the
PATH
variable is correctly set, though pipenv tries to use thelocal
prefix for calling python for some reason.May you please help me sorting this out?
Thanks
EDIT: I think I got the point where the issue starts, that is in
environment.py
, in functionscript_basedir
which gets the paths fromsysconfig.get_paths
, settingbase
andplatbase
variables to the virtual environment prefix. That function returns for the scripts key/my/custom/venv/path/local/bin
.Now the question is: if it uses
sysconfig.get_paths
to findpython
, shouldn't it setPATH
and the symlink topython
accordingly, during the initial setup?EDIT2:
reading sysconfig.py from the OS installation, the following is written:
Thus in pipenv's
environment.py
file,script_basedir
function, if I overwrite theinstall_scheme
as follows:the path is now correct again.
The problem seems to be fixed now. I wonder if this is the default Python behavior, of if it's some kind of Fedora 36 customization?
EDIT3:
and I'm still unsure whether the EDIT2 sysconfig.py code is a custom Fedora add-in, but I found this issue on the CPython github: python/cpython#89576
The text was updated successfully, but these errors were encountered: