Skip to content

Improved Package Resolution Algorithm #16

@DavePearce

Description

@DavePearce

(@altmattr this may interest you)

Currently, the manner which packages are resolved is problematic. Specifically, when we have two packages which depend on different versions of a third. This is the classic problem of transitive dependencies, of course!! Currently, the resolution algorithm activates all versions of a given dependency. This completely fails because Whiley currently has no support for handling multiple versions of a given package. Hence, you can't tell which version you are actually compiling against and I don't even know which one will be generated.

Maven (see [1]):

Maven picks the "nearest definition". That is, it uses the version of the closest dependency to your project in the tree of dependencies. You can always guarantee a version by declaring it explicitly in your project's POM

NPM (see here):

This package manager makes little effort to handle resolution, and appears to simply allow different versions of a package to coexist.

Cargo (see here):

This appears to allow different versions of a package to coexist. However, it doesn't allow multiple versions which semver compatible to coexist. The algorithm is employ is a relatively simple DFS approach. There are some "bombs" which can explode the amount of work it performs (see here).

Rust also employs the Cargo.lock file which helps to mitigate the cost of solving the dependency graph. Specifically, this maps out all the packages which are activated.

Thoughts

Overall, Rust seems to have a sensible approach. However, a critical aspect of this is that it allows multiple activations of the same package (provided they are semver incompatible). For example, v2.x can be activated alongside v1.x. This means adding support for multiple package activations to Whiley.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions