Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › deployment

Our Deploy Tool Decided 2.9.0 Was Newer Than 2.10.0: Why It Happens and How to Fix It

By Freedom251 Team · · 4 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If both values are valid Semantic Versioning 2.0.0 versions, 2.10.0 is the newer release and 2.9.0 is older. A deploy tool that ranks 2.9.0 above 2.10.0 is almost certainly comparing the version labels as text, or applying a different ordering scheme from the one your project uses. The fix is to compare the numeric parts of each version, and to write a test that pins the 2.9.0 versus 2.10.0 case.

The tool’s name and version are not given in the report, so the causes below are the most likely explanations from the symptom. They are not confirmed for your tool until you check its comparison code or configuration.

As an Amazon Associate I earn from qualifying purchases.

Why 2.10.0 is newer than 2.9.0

Semantic Versioning writes a version as MAJOR.MINOR.PATCH. Each element is an integer, and precedence is decided by comparing the elements from left to right. The first element that differs settles the order. The Semantic Versioning 2.0.0 specification states that each element MUST increase numerically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Applied to the pair in question, the comparison runs like this:

#1 Best Overall
  • Major: 2 versus 2. They are equal, so the comparison continues.
  • Minor: 9 versus 10. They differ, and 10 is the larger integer. The comparison stops here.
  • Patch: 0 versus 0. This is never reached, because the minor element has already decided the order.

Read as numbers, the minor element of 10 is greater than 9. Read as a sentence, “two-ten” is later than “two-nine.”

How a tool can get the order backwards

The most common cause is a string comparison. Text comparison reads the characters of each label in turn. For 2.9.0 and 2.10.0, the first two characters, “2.” are identical. The next character is “9” in one label and “1” in the other. Since “9” sorts after “1” as a character, the label 2.9.0 appears to be the larger one. That is exactly the reversed result you are seeing.

The table shows how the same pair can rank differently depending on the comparator.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Comparator How it reads 2.9.0 and 2.10.0 Result
Numeric SemVer comparison (major, minor, patch as integers) Minor 10 is greater than minor 9 2.10.0 is newer
Plain text comparison of the labels Character “9” sorts after character “1” 2.9.0 appears newer (the reported symptom)
Another scheme defined by a package manager or ecosystem Uses that ecosystem’s own rules Depends on the scheme; Maven states its ordering algorithm is not compatible with SemVer 2.0.0, and the pair’s result is not stated in the source reviewed

A text comparison is the simplest explanation, but it is not the only one. The tool might parse the version with a library that uses a different scheme, or it might have a defect in its own comparison logic. Confirm which one applies before you describe the cause as certain.

How to find the comparator your tool actually uses

  1. Reproduce the result in isolation. Run the tool’s version-selection step against a list containing only 2.9.0 and 2.10.0. Note which one it returns as the latest.
  2. Check the documentation for the version scheme. Look for a statement such as “versions follow Semantic Versioning” or a named ordering scheme. If the tool documents a scheme other than SemVer, its rules govern the result, not the SemVer rules.
  3. Identify the library that does the comparison. Many deploy tools delegate version ordering to a dependency. Check the lock file or dependency manifest for the package that provides version comparison, and read its documentation.
  4. Check configuration. Some tools expose a setting for the version format, a sort key, or a pattern used to pull versions from tags or artifact names. A misconfigured pattern can cause a version to be parsed as a different string than you expect.
  5. Inspect the comparison code. If the tool is open source or you maintain it, find where versions are sorted or where the latest release is chosen. Look for a sort on raw strings, such as a default sort applied to a list of version labels.

A regression test that pins the behavior

Once you know the comparator, add a test that fails when the order is reversed. The test should be written against the comparator your tool actually uses. If the tool uses SemVer, the assertion is straightforward:

assert compare_versions("2.9.0", "2.10.0") < 0   # 2.9.0 sorts before 2.10.0
assert latest(["2.9.0", "2.10.0"]) == "2.10.0"

In a numeric comparison, the same idea can be expressed by converting each label to a tuple of integers before comparing. For example, (2, 9, 0) compares less than (2, 10, 0). Avoid a fix that only handles three-part numeric versions if the deployment workflow accepts pre-release labels, since those need their own handling (see below).

Do not replace the tool’s comparator with a SemVer comparator if the tool intentionally follows another scheme. Establish which scheme controls release selection first, then test against that scheme’s rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Extended versions: pre-releases and build metadata

Semantic Versioning also defines labels that go beyond MAJOR.MINOR.PATCH. A few rules matter if your deployment compares full release strings:

  • Pre-releases sort lower than the normal version. 2.10.0-rc.1 comes before 2.10.0.
  • Pre-release identifiers are compared one at a time, left to right. Numeric identifiers compare as numbers, so alpha.2 comes before alpha.10. Non-numeric identifiers compare in ASCII order.
  • Build metadata after a plus sign does not affect precedence. 2.10.0+build.7 and 2.10.0+build.9 have the same precedence.

A comparator that treats these labels as plain text can still produce the reversed result for 2.9.0 and 2.10.0, and it will also mis-order pre-release labels like alpha.2 and alpha.10.

When the tool is not using SemVer

Some ecosystems define their own ordering rules, and those rules are not always compatible with Semantic Versioning. Maven’s version-ordering documentation says its algorithm is not compatible with SemVer 2.0.0. If your deployment pulls artifacts from a Maven repository, or the tool shares ordering logic with Maven, a SemVer test may pass while the tool still follows its own rules. In that case, write the test against the scheme the tool documents, and make sure your project’s release tags follow the same scheme so the two agree.

If you can share the tool’s name, its version, and the relevant configuration or comparison code, the cause can be pinned down more precisely.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

deploymentRelease Engineeringsemantic versioningTroubleshootingversion comparison

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.