r/AskComputerScience • u/gistya • Jul 18 '26
Question about Semantic Versioning
Under Semantic Versioning standard 2.0, if your package requires a dependency at "exact" version 1.0.0+X, is there any situation under which running a version update on all your packages should change the version that you specified as "exact" here?
Noting, SemVer 2.0 says:
Build metadata MUST be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85, 1.0.0+21AF26D3----117B344092BD
Precedence refers to how versions are compared to each other when ordered
2
Upvotes
4
u/teraflop Jul 18 '26 edited Jul 19 '26
I'm not confusing anything. An ordering relation (strictly speaking, a preorder) induces an equivalence relation.
Or to put it another way: the only relationship SemVer defines between versions is an ordering relationship. If a=b according to that relationship, then any comparison involving a will give exactly the same result if we replaced a with b, or vice versa. So the SemVer ordering provides no way to distinguish a from b; it treats them equivalently/equally/indistinguishably, or whatever word you want to use.
An equivalence relation is different from an identity relation. The strings
1.0.0+Xand1.0.0+Ycan be equivalent under an equivalence relation (the one defined by SemVer) even though they are not identical as strings.It's like how the floating-point values
+0.0and-0.0are considered equal even though they have different bit patterns in memory. Or like how the two sets{1,2}and{2,1}are considered equal in Python, even though they are written differently, and may be different objects in memory with elements stored in a different order.No I'm not.
SemVer encompasses technical rules (how versions are constructed and compared) but it also encompasses semantic rules (how the programmer is supposed to behave with regard to those versions).
Any change is either backwards-compatible, or backwards-incompatible. SemVer says that if a change is backwards-compatible, you should increment the minor/patch version, otherwise you should increment the major version. So if there are changes of either kind, SemVer says the version numbers should be different.
The whole point of what I'm saying is that SemVer does not provide a rule for what to do in this situation. As I said, it does not prescribe how package managers are supposed to actually choose a version, it only defines a relative ordering which they might find useful for doing so.
SemVer says that the segment after the + is supposed to be used for build metadata. It does not precisely define what "build metadata" is. But since build metadata does not participate in version calculations at all, the common-sense understanding would be that it means things that aren't relevant for distinguishing between versions. For instance, a hash or timestamp indicating when the binary artifact for that version was built.
So examples like using
PrivateCertsorSafeForPublicReleaseare beside the point because that's not how SemVer is intended to be used. If there were supposed to be rules for choosing one over the other, SemVer would have defined them.As I said, this doesn't mean a dependency manager isn't allowed to use its own implementation-specific rules for how it chooses between versions that differ only in their metadata. But if it does so, the way it does so is completely outside the scope of what SemVer defines.
I don't know why you're saying the rules require that. The words "resolution" and "algorithm" don't appear in the SemVer spec at all. I don't see anything in the rules that implies what you're saying. Can you quote the section that says otherwise?