infinitered / solidarity

Solidarity is an environment checker for project dependencies across multiple machines.
https://infinitered.github.io/solidarity/
MIT License
639 stars 49 forks source link

Solidarity cannot parse Java 11.0.16 correctly #269

Open tnguyen42 opened 1 year ago

tnguyen42 commented 1 year ago

For some reason, using this configuration of java:

{
        "rule": "cli",
        "binary": "java",
        "version": "--version",
        "semver": ">=11 <12"
      }

seems to work correctly for most Java version, but Solidarity doesn't identify Java 11.0.16 as a valid version. My guess is that the version isn't parsed correctly. Is this an easy fix?

Additional information: The output of java --version using this version is:

openjdk 11.0.16.1 2022-07-19 LTS
OpenJDK Runtime Environment Zulu11.58+23-CA (build 11.0.16.1+1-LTS)
OpenJDK 64-Bit Server VM Zulu11.58+23-CA (build 11.0.16.1+1-LTS, mixed mode)

While the output of java --version using 11.0.17 (which works) is:

openjdk 11.0.17 2022-10-18 LTS
OpenJDK Runtime Environment Zulu11.60+19-CA (build 11.0.17+8-LTS)
OpenJDK 64-Bit Server VM Zulu11.60+19-CA (build 11.0.17+8-LTS, mixed mode)
iegik commented 1 year ago

@tnguyen42 Hi! When I reinvented Solidarity in Bash yesterday, I have noticed, that semver binary do not correctly understand version number containing only major or major and minor version numbers. You need to provide full SemVer pattern (x.x.x) like >=11.0.0 <12.0.0.

{
        "rule": "cli",
        "binary": "java",
        "semver": ">=11.0.0 <12.0.0",
        "error": "You have java@{{installedVersion}}. Fix with `sdk install java {{wantedVersion}} && sdk use java {{wantedVersion}}`. More info https://sdkman.io/install"
      }

semver "14.3" -r ">=13.0.0" vs semver "14.3" -c -r ">=13.0.0" will have different result

-c --coerce Coerce a string into SemVer if possible (does not imply --loose)