composer / package-versions-deprecated

:package: Composer addon to efficiently get installed packages' version numbers
MIT License
1.51k stars 9 forks source link

composer-plugin-api version mismatch with Composer 2 #15

Closed kdambekalns closed 4 years ago

kdambekalns commented 4 years ago

As described in https://github.com/doctrine/orm/issues/8320, trying to update a project using doctrine/orm 2.7 with Composer 2.0.2 leads to an error message:

The "ocramius/package-versions" plugin was skipped because it requires a Plugin API version ("^1.0.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.

But ocramius/package-versions is "not installed":

$ composer show ocramius/package-versions
  [InvalidArgumentException]
  Package ocramius/package-versions not found

So we ask why it's there:

$ composer why ocramius/package-versions
composer/package-versions-deprecated  1.11.99  replaces  ocramius/package-versions (1.11.99)
ocramius/package-versions             2.2.0    replaces  composer/package-versions-deprecated (*)

… and find out it's replaced by composer/package-versions-deprecated:

$ composer show composer/package-versions-deprecated
name     : composer/package-versions-deprecated
[…]
requires
composer-plugin-api ^1.1.0 || ^2.0
php ^7 || ^8
[…]
replaces
ocramius/package-versions 1.11.99

It seems as if that correcrly declares a dependency on composer-plugin-api ^1.1.0 || ^2.0 but that is not used. Instead the dependency on composer-plugin-api: ^1.0.0 from the replaced https://packagist.org/packages/ocramius/package-versions#1.4.2 seems to be picked up?!

Is this a bug with composer/package-versions-deprecated or with Composer itself? Or even expected (but unfortunate) behaviour?

Seldaek commented 4 years ago

IMO using composer/package-versions-deprecated is the correct choice for doctrine/orm, until they can decide to support only composer 2 and then they could use our native InstalledVersions implementation.

That said.. I have no idea what error you are referring to. Please provide a way to reproduce this, composer.json, and the full command+output you are seeing. Because this "error" in isolation does not tell me anything.

Seldaek commented 4 years ago

Ah.. Actually it seems like perhaps you have ocramius/package-versions installed globally and that is what the warning is about. Check with composer global show if it's there. Maybe you need to update your global dependencies.

kdambekalns commented 4 years ago

Actually it seems like perhaps you have ocramius/package-versions installed globally

😱 Indeed, that was the case. Updating globally solved the issue.

Thanks for the response and the new and improved output!

Seldaek commented 4 years ago

Ok great thanks for confirming :)