-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Dependency resolution picks wrong version of url dependency when lock file exists #4550
Comments
This is the first time I've poked around in
When the lock file exists, the dependency doesn't change versions and poetry tries to install the wrong version. When the lock file doesn't exist, the dependency changes to the correct version. |
Oh, looks like the lock file is just... incorrectly written? The issue can be manually resolved by editing the [[package]]
name = "lib1"
version = "0.1.0"
description = ""
category = "dev"
optional = false
python-versions = "^3.6.1"
develop = true
[package.dependencies]
ray = {url = "https://s3-us-west-2.amazonaws.com/ray-wheels/master/cd22a7d1bbf38f66aa8b735459319ff24f102a20/ray-2.0.0.dev0-cp36-cp36m-manylinux2014_x86_64.whl", extras = ["default"], markers = "python_version >= \"3.6\" and python_version < \"3.7\" or python_version >= \"3.7\" and python_version < \"3.8\""} to [[package]]
name = "lib1"
version = "0.1.0"
description = ""
category = "dev"
optional = false
python-versions = "^3.6.1"
develop = true
[package.dependencies]
ray = [
{url = "https://s3-us-west-2.amazonaws.com/ray-wheels/master/cd22a7d1bbf38f66aa8b735459319ff24f102a20/ray-2.0.0.dev0-cp36-cp36m-manylinux2014_x86_64.whl", extras = ["default"], markers = "python_version >= \"3.6\" and python_version < \"3.7\""},
{url = "https://s3-us-west-2.amazonaws.com/ray-wheels/master/cd22a7d1bbf38f66aa8b735459319ff24f102a20/ray-2.0.0.dev0-cp37-cp37m-manylinux2014_x86_64.whl", extras = ["default"], markers = "python_version >= \"3.7\" and python_version < \"3.8\""}
] The only change here is to the |
It looks like this block erroneously merges the two Both share the same
I still haven't totally grokked all of the poetry internals, but it seems to me that URLDependencies should not be merged in this way. With that in mind, I tried what is probably a hacky fix to if all(isinstance(dep, URLDependency) for dep in deps):
_deps = deps
else: This makes the generated lock file work correctly for fresh installation, as it now contains the python 3.7 version of [[package]]
name = "lib1"
version = "0.1.0"
description = ""
category = "dev"
optional = false
python-versions = "^3.6.1"
develop = true
[package.dependencies]
ray = {url = "https://s3-us-west-2.amazonaws.com/ray-wheels/master/cd22a7d1bbf38f66aa8b735459319ff24f102a20/ray-2.0.0.dev0-cp37-cp37m-manylinux2014_x86_64.whl", extras = ["default"], markers = "python_version >= \"3.7\" and python_version < \"3.8\""} I would imagine that this issue also affects vcs/file/directory dependencies. My hack won't work for those cases, obviously. |
Hey @abn, finswimmer told me to ping you. I did the work of finding the cause of this bug, and I am happy to work on a fix for this, just need a bit of guidance on what you think the best course of action is. Thanks! |
Just bumping this. Experienced the same issue, removing the generated lock file and regenerating works. Any updates on maybe a PR? |
Should be resolved in master via #5715 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).TLDR
In my last comment, I identified what the cause of the bug was and made a hacky fix to workaround the issue. Someone more familiar with
poetry
should probably make the appropriate fix.Issue
When a library depends on another library via a path which has a url dependency with multiple python version constraints, the dependency resolver appears to always picks the lowest python version of the dependency regardless of the python version in use by the poetry environment if a lock file exists. Deleting the lock file "resolves" the issue, and the correct version of the dependency is installed, however the generated lock file causes the issue again.
Let me demonstrate with a minimal example. The gist linked above includes two
pyproject.toml
files and the directory structure I am using. From a high level:To set up this minimal repro, I created the libraries with
poetry new lib1 --src
andpoetry new lib2 --src
. I then manually edited the appropriatepyproject.toml
files, adding the "complex" url dependency forlib1
and thelib1
dependency forlib2
.The directory structure looks like this:
Initially no lock file exists and the installation is successful.
Now, let's remove the environment (as if I've just cloned this repository, for example) and try installing while the lock file exists.
As you can see, poetry tried to install the python 3.6 version of the
ray
url dependency fromlib1
. I should note also that I did update pip as the warning recommends, but as expected this issue is unrelated to that.Removing the lock file (which was generated from the successful installation) and running
poetry install
again is successful however.Interestingly, there are a lot of references to the python 3.6 version of
ray
even in the output of the dependency resolution (prior to the "Writing lock file" line) even in this case, however it does install the correct version.The text was updated successfully, but these errors were encountered: