Jean85/pretty-package-versions

Undefined class constant 'ROOT_PACKAGE_NAME'

Closed this issue · 11 comments

In version 1.5.1:

PHP Fatal error:  Uncaught FatalThrowableError: Undefined class constant 'ROOT_PACKAGE_NAME' in vendor/jean85/pretty-package-versions/src/PrettyVersions.php:23

1.5.1 requires this:

"composer/package-versions-deprecated": "^1.8.0"

Which version of that package are you using? Because it does have that constant (even if deprecated): https://github.com/composer/package-versions-deprecated/blob/7413f0b55a051e89485c5cb9f765fe24bb02a7b6/src/PackageVersions/Versions.php#L27

None:

php composer.phar show | grep version                      
composer/semver                      1.5.1                            Semver library that offers utilities, version constraint parsing and validation.
jean85/pretty-package-versions       1.5.1                            A wrapper for ocramius/package-versions to get pretty versions strings
ocramius/package-versions            2.1.0                            Provides efficient querying for installed package versions (no runtime IO)
openlss/lib-array2xml                1.0.0                            Array2XML conversion library credit to lalit.org
phar-io/version                      2.0.1                            Library for handling version information and constraints
ramsey/uuid                          3.7.3                            Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).
sebastian/version                    2.0.1                            Library that helps with managing the version number of Git-hosted PHP projects
symfony/polyfill-php72               v1.18.1                          Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73               v1.18.1                          Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80               v1.18.1                          Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions

Not sure how it's possible to resolve dependencies without it?

I required it and nothing changed:

php composer.phar require composer/package-versions-deprecated
Using version 1.11.99.1 for composer/package-versions-deprecated
./composer.json has been updated
Running composer update composer/package-versions-deprecated
Loading composer repositories with package information
Updating dependencies                                 
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove

I'm using composer 2.0.

Ocramius' package 2.x is eagerly replacing ALL the versions of the forks :(

https://github.com/Ocramius/PackageVersions/blob/2.4.x/composer.json#L25

The replace is incorrect, should've replaced 2.* only :( but I understand the defensive approach.

On my side, I think that the only way out of this is with a new minor/major that requires Composer 2 and drops any further dependency.

On my side, I think that the only way out of this is with a new minor/major that requires Composer 2 and drops any further dependency.

That sounds good to me.

@Jean85 Is plan to require Composer 2 and drop any further dependency still valid?

I just tagged 2.0! Yes!

2.0 uses Composer APIs directly, and those are required.
Also, this bug is caused by Ocramius/PackageVersions#165 and I can't do anything more to resolve it in the 1.x series; if you're locked on Composer 1, the only possible workaround to avoid it is to restrict your own composer.json requirements to avoid installing ocramius/package-versions 2.x.

Oh, now sentry/sentry, sentry/sentry-symfony, phpstan/phpstan, phpstan/phpstan-symfony...need to support major version.

Thanks anyway, but looks like this will not be a quick propagation.

I'm a Sentry maintainer, so that's easy! Regarding PHPStan, it's being shipped as a shimmed PHAR since a long time ago.

I'll open PRs ASAP to propagate it.

Great, thanks!