-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistency when patch version is leaved out in VersionReq #128
Comments
Yeah, I'm not sure this is a well-formed requirement. Hmmmm |
@steveklabnik You meant But since it's not well-documented and actually requirements like |
The semver spec doesn't discuss matchers at all, so there's more freedom here. We should investigate what matchers bundler and npm accept. |
Version constraint ...invalid in const semver = require('semver')
semver.satisfies('^0.30-beta', '0.30.0-beta') // TypeError: Invalid Version: ^0.30-beta ...valid in use Composer\Semver\Semver;
var_dump(Semver::satisfies('0.30.0-beta', '^0.30-beta')); // bool(true) ...valid in puts Gem::Dependency.new('', '~> 0.30-beta').match?('', '0.31.1'); // true |
Actually Semver does specify this, in an indirect way:
This seems to imply that the the specification must have a patch version number for a version with pre-release tag to be compatible. That seems to implies that either requirements like Of course trying to interpret the specifications as literally as possible is not necessarily useful. But if we are to allow rules like
Personally I'd like to simplify the rules by:
Note that the above implies Then there's the question of how many project builds would get broken by changing the rules now. I suspect it wouldn't be too bad since prerelease tags aren't used very much and most version specifications are of the form @steveklabnik I hope you are okay making some minor changes here? I'm quite happy to make a PR but we need to make some decisions first. |
I am okay with making some changes, as long as they're going towards the spec and not away from it. :) In general, getting us to be compatible with npm's implementation is my goal. I actually wanted to make a comparison between major implementations, but hadn't had the time yet... I'm super busy at the moment (just showed up at the work week) so I can't fully commit to a direction here, but it seems like we should change this; that is, in line with the principle above. |
It seems like prerelease tags are only expected when a patch version is present, making Regarding the other issue, it's not very clear whether NPM considers |
@isaacs if you have a chance, any comment on ☝️ |
There's some confusion here about what spec governs semver ranges. SemVer.org has detailed specifications for semver versions, but says nothing about ranges. (In the 2.0 version of the spec, the word "match" was struck entirely, specifically because it is ambiguous and confusing to talk about "matching" without treating ranges and versions separately. Versions don't match/satisfy one another; versions satisfy ranges, ranges match versions.) The most popular existing implementation of semver ranges (by usage) is node-semver. So I'll treat that as if it's a spec, and talk about how it handles ranges and specifically, ranges with prerelease tags. In node-semver,
You could do something like There is no way with node-semver ranges to specify "any version at or above Prerelease tags are a separate universe that lives in a pre-committed state. It's "allowed" by the SemVer specification to have a
Yes, it does:
According to the SemVer spec, a prerelease tagged version is lower in the sort ordering than its non-prerelease-tagged counterpart.
However, note that
There's no law of the universe that says that this implementation of semver in Rust necessarily must match the implementation of semver in JavaScript, but if that is the goal, this is the answer. And if y'all go a different way on this, it's probably worth mentioning in the docs or something, so users of npm and cargo don't get confused :) |
This is fixed in 1.0.0 — This aligns with the grammar described in https://github.com/semver/semver/blob/efcff2c838c9945f79bfd21c1df0073271bcc29c/ranges.md. |
If I have a requirement like
0.30
, it would match0.30.0
. However if the requirement is0.30-beta.1
, it does not match0.30.0-beta.1
.I just went through the SemVer documentation without finding much related info. Actually I doubt whether such a requirement is really allowed?
Playground
The text was updated successfully, but these errors were encountered: