-
-
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 Lock (Or Install) Does Not Respect Index Specified For A Package #4637
Comments
I can second this behaviour. It's causing a lot of trouble recently, since I didn't know about "dependency confusion" as a risk. Now we published a library to an internal package index that has recently gotten a "competitor" at pypi.org. Pipenv lets me specify the correct index, but doesn't honor it when running |
Thanks @janneronkko for saving me the time to describe the bug in full! |
This comment was marked as resolved.
This comment was marked as resolved.
Ah-ha I got it to run. because I changed the path to not use venv I had to also remove that from the
Also checked it on my pip 22.0.4 branch and that also has the issue. |
Actually I am wondering if this will even be possible to exclude pypi from the search indexes within pip. |
@frostming If you have time to have your attention drawn to this issue, I think it is critically important based on the reproduction. There are a couple issues at play here, but the primary one of this ticket is that the resolver is not respecting the index specifications for a particular requirement. |
I messed around with this most of the day without much success, like there was some forward progress but ultimately broke a bunch of tests so not really progress. I did learn these three things: |
This is going to be fairly hard to solve I think. For 2.) the resolver not respecting the indexes ... we create one pip package finder and one pip resolver to resolve all requirements. Pipenv's Resolver knows about the |
That being said, I have an experimental branch that changed vendor'd code including pip code to try and solve for this problem. In my branch |
Ok I opened a PR, 1 test is failing when run in the group but when I run it singularly it passes every time (but also fails locally if I run the whole group). Will have to investigate that, and what can be done to support what I am trying to do within pip, since I modified the pip internals for part of it: #4983 However, it does seem to fix your issue at least in terms of your example test. |
@matteius Thanks for taking the time to do this, I do believe this could fix a serious security issue! |
@janneronkko or @reinvantveer this is mostly set, but I've run into some snags adding a unit test to the project for it. May be able to move forward with out that, but its not ideal. @janneronkko example involves running two pypi test servers and generating a test package on the fly. We have a test fixture for a single pypi test server but I think its port is dynamic and some other differences making the script hard to port. I had started something for it but lost those changes in my stash when I had to destroy my local copy and reclone, but its ok because I hadn't gotten very far. If either of you have time to consider the testing angle that could really help prevent future regressions. |
I merged the fix in master -- feel free to respond if you have ideas on getting a test in place. Wanted to ensure that the fix gets in the next release however. |
|
Issue description
Index argument for a package is not respected
Expected result
Pipenv only installs (locks) versions from specified package index.
Actual result
Pipenv installs (locks) the package with greatest version from a package index not specified in the Pipfile.
Steps to replicate
Run the following script:
The script creates two versions of example Python packge (version 1 and 2). Then it starts pypi server; server 1 contains example version 1 and server 2 contains example version 2.
The Pipfile states that example package of any version should be installed from index server1 (that contains only version 1 of example package).
The result is that version 2 of example package is installed (from server 2)
Documentation (https://pipenv.pypa.io/en/latest/advanced/#specifying-package-indexes) states:
$ pipenv --support
Pipenv version:
'2020.11.15'
Pipenv location:
'/usr/lib/python3.9/site-packages/pipenv'
Python location:
'/usr/bin/python'
Python installations found:
3.9.2
:/usr/bin/python3.9
3.9.2
:/usr/bin/python3
3.7.9
:/usr/bin/pypy3
2.7.18
:/usr/bin/python2.7
2.7.18
:/usr/bin/python2
PEP 508 Information:
System environment variables:
SHELL
SESSION_MANAGER
WINDOWID
QT_SCREEN_SCALE_FACTORS
COLORTERM
XDG_SESSION_PATH
HISTCONTROL
TMUX
HISTSIZE
LANGUAGE
LC_ADDRESS
LC_NAME
SSH_AUTH_SOCK
HISTTIMEFORMAT
SHELL_SESSION_ID
DESKTOP_SESSION
LC_MONETARY
SSH_AGENT_PID
GTK_RC_FILES
XCURSOR_SIZE
CLOUDSDK_PYTHON_ARGS
EDITOR
GTK_MODULES
XDG_SEAT
PWD
XDG_SESSION_DESKTOP
LOGNAME
XDG_SESSION_TYPE
XAUTHORITY
MOTD_SHOWN
GTK2_RC_FILES
HOME
LC_PAPER
LANG
HISTFILE
XDG_CURRENT_DESKTOP
KONSOLE_DBUS_SERVICE
CLOUDSDK_ROOT_DIR
KONSOLE_DBUS_SESSION
PROFILEHOME
XDG_SEAT_PATH
KONSOLE_VERSION
KDE_SESSION_UID
CLOUDSDK_PYTHON
XDG_SESSION_CLASS
TERM
LC_IDENTIFICATION
GOOGLE_CLOUD_SDK_HOME
USER
TMUX_PANE
COLORFGBG
KDE_SESSION_VERSION
PAM_KWALLET5_LOGIN
VISUAL
DISPLAY
SHLVL
LC_TELEPHONE
LC_MESSAGES
LC_MEASUREMENT
XDG_VTNR
XDG_SESSION_ID
MOZ_PLUGIN_PATH
LC_CTYPE
XDG_RUNTIME_DIR
LC_TIME
QT_AUTO_SCREEN_SCALE_FACTOR
LC_COLLATE
XCURSOR_THEME
KDE_FULL_SESSION
PATH
HISTFILESIZE
DBUS_SESSION_BUS_ADDRESS
KDE_APPLICATIONS_AS_SCOPE
HG
MAIL
LC_NUMERIC
OLDPWD
_
PIP_DISABLE_PIP_VERSION_CHECK
PYTHONDONTWRITEBYTECODE
PIP_SHIMS_BASE_MODULE
PIP_PYTHON_PATH
PYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH
:/home/janne/bin:/usr/lib/colorgcc/bin:/opt/google-cloud-sdk/bin:/home/janne/bin:/usr/lib/colorgcc/bin:/home/janne/bin:/usr/lib/colorgcc/bin:/opt/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/jvm/default/bin
SHELL
:/bin/bash
EDITOR
:vim
LANG
:en_US.UTF-8
PWD
:/home/janne/tmp/pipenvbug
Contents of
Pipfile
('/home/janne/tmp/pipenvbug/Pipfile'):Contents of
Pipfile.lock
('/home/janne/tmp/pipenvbug/Pipfile.lock'):The text was updated successfully, but these errors were encountered: