phive icon indicating copy to clipboard operation
phive copied to clipboard

Version '4.0.0beta1' is not supported

Open jrfnl opened this issue 8 months ago • 4 comments

I get the impression a - is expected between the 4.0.0 and beta1, but that's not required for the PHP version_compare() function

Phive 0.16.0 - Copyright (C) 2015-2025 by Arne Blankerts, Sebastian Heuer and Contributors
Fetching repository list
Downloading repositories.xml [https://phar.io/data/repositories.xml]

 ╰|========================================>| 138 B / 138 B - 100%
Downloading phive.xml [https://phars.phpcodesniffer.com/phars/phive.xml]

 ╰|========================================>| 22.15 KB / 22.15 KB - 100%
Error: [ERROR]   An error occurred while processing your request:

          Version string '4.0.0beta1' does not follow SemVer semantics
          
          #0 vendor/phar-io/version/src/Version.php(201)
          #1 vendor/phar-io/version/src/Version.php(32): PharIo\Version\Version->ensureVersionStringIsValid()
          #2 src/shared/repository/PharIoRepository.php(34): PharIo\Version\Version->__construct()
          #3 src/commands/install/InstallCommand.php(68): PharIo\Phive\PharIoRepository->getReleasesByRequestedPhar()
          #4 src/commands/install/InstallCommand.php(56): PharIo\Phive\InstallCommand->resolveToRelease()
          #5 src/commands/install/InstallCommand.php(51): PharIo\Phive\InstallCommand->installRequestedPhar()
          #6 src/shared/cli/Runner.php(241): PharIo\Phive\InstallCommand->execute()
          #7 src/shared/cli/Runner.php([9](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/runs/14952435282/job/42003688786#step:7:10)5): PharIo\Phive\Cli\Runner->execute()
          #8 (355): PharIo\Phive\Cli\Runner->run()
          #9 {main}

          Environment: PHP 8.4.7 (on Linux 6.11.0-[10](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/runs/14952435282/job/42003688786#step:7:11)13-azure)
          Phive Version: 0.16.0

          This should not have happened and is most likely a bug.
          Please report it at https://github.com/phar-io/phive/issues, make sure you include
          the full output of this error message. Thank you!

The error can be seen in the release verification job for PHP_CodeSniffer: https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/runs/14952449073/attempts/1

I suppose I can rename the related files to have a - specifically for PHIVE, but figured I'd report this as, as far as I can see, there is no reason this shouldn't be supported.

jrfnl avatar May 11 '25 05:05 jrfnl

I suppose I can rename the related files to have a - specifically for PHIVE, but figured I'd report this as, as far as I can see, there is no reason this shouldn't be supported.

Actually there is a reason for not supporting it: It's not valid according to the semver spec as I understand it.

In Section 9 on Pre-Releases it states:

A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers MUST NOT include leading zeroes. [....]. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92, 1.0.0-x-y-z.--.

See https://semver.org/#spec-item-9.

theseer avatar Jun 12 '25 21:06 theseer

@theseer Good point. As PHP itself doesn't use the dash for their releases, I had the mistaken idea that the dash was optional.

jrfnl avatar Jun 14 '25 11:06 jrfnl

version_compare can deal with a lot of ... interesting ... version strings. And, PHP isn't actually following semver either.

So, I guess that's not a compelling argument ;-)

theseer avatar Jun 14 '25 13:06 theseer

Wasn't intended as one. Might be good to document somewhere that tags need to comply with semver ?

jrfnl avatar Jun 14 '25 13:06 jrfnl