conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.31k stars 986 forks source link

[bug] version conflict regardless of allowed version ranges #17168

Closed ldrozdz93 closed 1 month ago

ldrozdz93 commented 1 month ago

Describe the bug

Environment details: any profile. Conan version 2.7.0.

Context

My package requires "libmysqlclient/8.1.0" and "lz4/[^1.9]", so for lz4 both v1.9.4 and v1.10.0 are allowed. The "libmysqlclient/8.1.0" package requires "lz4/1.9.4", so only v1.9.4 is allowed. lz4/1.10.0 is in the local cache.

Expected behaviour

Given that both my package and libmysqlclient agree on lz4/1.9.4, then it should be used, regardless of the cache content.

Actual Behaviour

A version conflict is reported if lz4/1.10.0 exists in the local cache, as if my package required v.10.0 instead of just allowing it. If I remove lz4/1.10.0 from the local cache, then the versions are resolved without errors. Cache content influences the version resolution.

In symbolic terms

If

How to reproduce it

root@61b51a4b67a5:/conan/bug# cat conanfile.py 
from conan import ConanFile

class BugRecipe(ConanFile):
    name = "bug-cpp"
    version = "0.0.0"

    def requirements(self):
        self.requires("lz4/[^1.9]")
        self.requires("libmysqlclient/8.1.0")

root@61b51a4b67a5:/conan/bug# conan install --requires="lz4/1.10.0"  --profile:all=clang-18 --build=missing
...
...
lz4/1.10.0: Package 'a6f01175d41f4b1fc15f4ca19fea392b8d74bcfb' created
...
Install finished successfully

root@61b51a4b67a5:/conan/bug# conan install .  --profile:all=clang-18 --build=missing
...
======== Computing dependency graph ========
Graph root
    conanfile.py (bug-cpp/0.0.0): /conan/bug/conanfile.py
Requirements
    libmysqlclient/8.1.0#ecca1993f7ce32371ef5436f3639074a - Cache
    lz4/1.10.0#68a01ece147a441b463d8cefea68d555 - Cache
    openssl/3.3.1#279e86dc2a7dded8c1fe8512e775bdb1 - Cache
    zlib/1.3.1#f52e03ae3d251dec704634230cd806a2 - Cache
    zstd/1.5.5#1f239731dc45147c7fc2f54bfbde73df - Cache
Resolved version ranges
    lz4/[^1.9]: lz4/1.10.0
    openssl/[>=1.1 <4]: openssl/3.3.1
    zlib/[>=1.2.11 <2]: zlib/1.3.1
ERROR: Version conflict: Conflict between lz4/1.9.4 and lz4/1.10.0 in the graph.
Conflict originates from libmysqlclient/8.1.0

root@61b51a4b67a5:/conan/bug# conan remove lz4/1.10.0 -c
Remove summary:
Local Cache
  lz4/1.10.0#68a01ece147a441b463d8cefea68d555: Removed recipe and all binaries

root@61b51a4b67a5:/conan/bug# conan install .  --profile:all=clang-18 --build=missing
...
======== Computing dependency graph ========
Graph root
    conanfile.py (bug-cpp/0.0.0): /conan/bug/conanfile.py
Requirements
    libmysqlclient/8.1.0#ecca1993f7ce32371ef5436f3639074a - Cache
    lz4/1.9.4#652b313a0444c8b1d60d1bf9e95fb0a1 - Cache
    openssl/3.3.1#279e86dc2a7dded8c1fe8512e775bdb1 - Cache
    zlib/1.3.1#f52e03ae3d251dec704634230cd806a2 - Cache
    zstd/1.5.5#1f239731dc45147c7fc2f54bfbde73df - Cache
Resolved version ranges
    lz4/[^1.9]: lz4/1.9.4
    openssl/[>=1.1 <4]: openssl/3.3.1
    zlib/[>=1.2.11 <2]: zlib/1.3.1
...
Install finished successfully
memsharded commented 1 month ago

Hi @ldrozdz93

Thanks for your feedback.

This is most likely the intended behavior by design, have you had a look to https://docs.conan.io/2/knowledge/faq.html#getting-version-conflicts-even-when-using-version-ranges?

Please have a look, and let us know if there are more questions.

memsharded commented 1 month ago

Hi @ldrozdz93

Did you manage to have a look to that FAQ? Any further question?

ldrozdz93 commented 1 month ago

Thanks, I've understood the problem and just reordered the requirements :) You can close this issue

memsharded commented 1 month ago

Thanks very much for your feedback! :)