Skip to content

Use caret (^) comparison instead of == for required_version #6729

@wesleymatosdev

Description

@wesleymatosdev

So, for context, we had only a text comparison for required_version param. Then, on #6066 I introduced semver library so we didn't had to fix this ourselves nor maintain this complexity on this codebase.

One thing tho, is that the only values available for required_version at the time, were exact versions, which would generate an exact match. Which means we were not semver-compliant.

At the time, as this made sense for me to not break change the implementation, we should use == as the default behavior, instead of ^ when there is no operator on it. Because of that, I even opened dtolnay/semver#311 asking semver maintainer to include the option to use other default operator.

The thing is, a few days ago the issue was closed, with this justification:

This diverges from how version requirements with no comparison operator are treated by Cargo.
source: dtolnay/semver#311 (comment)

After digging a bit on that, according to The Cargo Book:

Caret requirements are the default version requirement strategy. This version strategy allows SemVer compatible updates. They are specified as version requirements with a leading caret (^).
source: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements

With this information, it makes sense to make this semver-compliant and follow the default Cargo behavior.

TL;DR: We should do the same as cargo does and use ^ as the default comparator instead of == which was used to kept the behavior from before we introduced semver-compliant behavior with semver library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions