Skip to content

dependency resolver sometimes fails to find valid resolution when optional dependencies have a conflict. #14891

Open
@Eh2406

Description

@Eh2406

Problem

In the resolver conflicts are stored as a list of package versions that cannot be activated the same time. This model is insufficient to describe certain interactions of optional features with requirements that can match multiple major versions. The exact root cause of the problem is not yet clear.

Steps

I have suspected there are issues with this for a long time. But it was only this week that I came across a clear reproducer.

#[test]
/// Minimized from `upstream-ontologist v0.1.37`, although subsequent changes to the index
/// means it's no longer a problem in the wild.
fn test() {
    let reg = registry(vec![
        pkg_dep(
            ("breezyshim", "1.0.0"),
            vec![dep("debversion").with(&["pyo3"])],
        ),
        pkg_dep(("debbugs", "1.0.0"), vec![dep_req("debversion", "^0.4")]),
        pkg_dep(("debversion", "0.3.1"), vec![dep("pyo3").opt()]),
        pkg_dep(
            ("debversion", "0.4.1"),
            vec![dep_req("pyo3", ">=0.22").opt()],
        ),
        pkg(("pyo3", "0.20.3")),
    ]);

    let deps = vec![dep("breezyshim"), dep("debbugs")];
    let mut sat_resolver = SatResolver::new(&reg);
    resolve_and_validated(deps, &reg, &mut sat_resolver).unwrap();
}

Possible Solution(s)

It should be possible to resolve this by directly modeling features as separately tracked entities in the existing resolver. This would however be a lot of work. I suspect this will not get fixed until we switch to a PubGrub based resolver.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions