Ocramius / PackageVersions

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

Support Composer bin plugin #220

Closed someniatko closed 2 years ago

someniatko commented 2 years ago

Composer bin plugin seems to not be supported.

This prevents, for instance, running roave/infection-static-analysis-plugin when it's installed in a separate "bin" alongside with infection and psalm.

PHP Fatal error:  Uncaught OutOfBoundsException: Package "vimeo/psalm" is not installed in /var/app/vendor/composer/InstalledVersions.php:203
Stack trace:
#0 /var/app/vendor/ocramius/package-versions/src/PackageVersions/Versions.php(36): Composer\InstalledVersions::getPrettyVersion('vimeo/psalm')
#1 /var/app/vendor-bin/qa/vendor/roave/infection-static-analysis-plugin/bin/roave-infection-static-analysis-plugin(55): PackageVersions\Versions::getVersion('vimeo/psalm')
#2 /var/app/vendor-bin/qa/vendor/roave/infection-static-analysis-plugin/bin/roave-infection-static-analysis-plugin(89): Roave\InfectionStaticAnalysis\Application\{closure}()
#3 /var/app/vendor/bin/roave-infection-static-analysis-plugin(120): include('/var/app/vendor...')
#4 {main}
  thrown in /var/app/vendor/composer/InstalledVersions.php on line 20
Ocramius commented 2 years ago

This library only relies on composer's internal mechanism being available: if that doesn't work for "bin plugins" (honestly, just have a clean composer.json+composer.lock in a different directory instead), you should report it in the bin plugin or in composer itself.

This library no longer messes with the plugin system of composer (and glad it doesn't).

someniatko commented 2 years ago

a clean composer.json+composer.lock in a different directory

That's essentially what the bin plugin does.

This library lets the check pass if the CWD is set to that different directory (with the composer.json containing psalm, infection and the infection plugin hack), however it doesn't if CWD is in the main project directory, with the main composer.json not containing those tools.

Ocramius commented 2 years ago

I really suggest bringing it up there then: there's really not much code left here