Repository navigation
Description
Describe the bug
When two version ranges have disjoint >= and < bounds whose internal version has a pre-release suffix, such as libgit2/[>=2.0.0-rc.1, include_prerelease] and libgit2/[<2.0.0-rc.1, include_prerelease] for libgit2 v2.0.0-rc.1, or adjacent tilde ranges such as nlohmann_json/[~3.10] and nlohmann_json/[~3.11] (which expand to >=3.10- <3.11- and >=3.11- <3.12-), VersionRange.intersection returns a void VersionRange ([>=2.0.0-rc.1 <2.0.0-rc.1, include_prerelease] or [>=3.11- <3.11-]) instead of None.
contains() on the void range still rejects all concrete versions, so no wrong package version is selected, but _conflicting_version in conan/internal/graph/graph_builder.py only raises GraphConflictError when intersection() returns None. Closing a diamond with these ranges skips conflict detection, queries cache (and remotes unless -nr is passed) for the unsatisfiable range, and fails with GraphMissingError ("type": "missing") instead of GraphConflictError ("type": "conflict").
Expected behavior: VersionRange.intersection returns None for disjoint >= and < bounds at the same version, matching VersionRange(">=2.0.0").intersection(VersionRange("<2.0.0")) is None, so conan graph info and conan install report ERROR: Version conflict: Conflict between ... in the graph.
In conan/internal/model/version_range.py, _Condition.__lt__ handles self.operator == ">=" when self.version == other.version (lines 76-84) with branches for other.operator == ">" and other.operator == "<=", leaving other.operator == "<" during the lower_limit <= upper_limit non-void check (line 263) to fall into else: return self.display_version.pre is not None (written for comparing two >= conditions). That returns True whenever lower_limit.display_version.pre is set (>=2.0.0-rc.1 or >=3.11-).
Environment:
- OS: Linux (x86_64)
- Conan version: 2.34.0 and 2.35.0-dev (
develop2at5fd213f27d72, reproduced atbffc2b506d7f) - Python version: 3.12
How to reproduce it
CLI reproduction with conan graph info:
mkdir -p repro/libgit2 repro/consumer && cd repro
cat > libgit2/conanfile.py <<'PY'
from conan import ConanFile
class Libgit2(ConanFile):
name = "libgit2"
PY
cat > consumer/conanfile.py <<'PY'
from conan import ConanFile
class Consumer(ConanFile):
name = "consumer"
version = "1.0.0"
requires = "libgit2/[>=2.0.0-rc.1, include_prerelease]"
PY
export CONAN_HOME="$PWD/.conan2"
conan profile detect
conan export libgit2 --version=1.8.4
conan export libgit2 --version=2.0.0-rc.1
conan export consumer
conan graph info --requires="consumer/[>=1.0.0]" --requires="libgit2/[<2.0.0-rc.1, include_prerelease]" -nrInstead of failing with ERROR: Version conflict: Conflict between libgit2/[>=2.0.0-rc.1, include_prerelease] and libgit2/[<2.0.0-rc.1, include_prerelease] in the graph., Conan constructs the void intersection libgit2/[>=2.0.0-rc.1 <2.0.0-rc.1, include_prerelease] and fails in RangeResolver with GraphMissingError (Package 'libgit2/[>=2.0.0-rc.1 <2.0.0-rc.1, include_prerelease]' not resolved: Version range '>=2.0.0-rc.1 <2.0.0-rc.1, include_prerelease' ... could not be resolved).
Direct check on VersionRange.intersection:
python3 -c '
from conan.internal.model.version_range import VersionRange
r1 = VersionRange(">=1.2.0-rc.1, include_prerelease")
r2 = VersionRange("<1.2.0-rc.1, include_prerelease")
inter = r1.intersection(r2)
print(f"Intersection of disjoint ranges: {inter.version() if inter else None} (expected None)")
'Actual output:
Intersection of disjoint ranges: [>=1.2.0-rc.1 <1.2.0-rc.1, include_prerelease] (expected None)
Credit: https://ucsbplse.github.io/
Activity
memsharded commentedon Nov 26, 2026
Hi @trackoor
Thanks for the report
Doing #20559, aiming for next Conan 2.35 release