laminas / laminas-component-installer

Composer plugin for injecting modules and configuration providers into application configuration
https://docs.laminas.dev/laminas-component-installer/
BSD 3-Clause "New" or "Revised" License
27 stars 12 forks source link

TypeError when using Composer 2.5.6 #69

Closed mimmi20 closed 1 year ago

mimmi20 commented 1 year ago

Bug Report

Q A
Version(s) 2.3.0

Summary

When using Composer 2.5.6 (see https://github.com/composer/composer/releases/tag/2.5.6) an TypeError occures when using MetaPackages like laminas/laminas-mvc-form

Current behavior

An TypeError is thrown

In ComponentInstaller.php line 754:

  [TypeError]
  Laminas\ComponentInstaller\ComponentInstaller::mapAutoloaders(): Argument #3 ($packagePath) must be of type string, null given, called in ...vendor/laminas/laminas-component-installer/src/ComponentInstaller.php on line 289

Exception trace:
  at ...vendor/laminas/laminas-component-installer/src/ComponentInstaller.php:754
 Laminas\ComponentInstaller\ComponentInstaller->mapAutoloaders() at ...vendor/laminas/laminas-component-installer/src/ComponentInstaller.php:289
 Laminas\ComponentInstaller\ComponentInstaller->loadModuleClassesDependencies() at ...vendor/laminas/laminas-component-installer/src/ComponentInstaller.php:955
 Laminas\ComponentInstaller\ComponentInstaller->addPackageToConfig() at ...vendor/laminas/laminas-component-installer/src/ComponentInstaller.php:218
 Laminas\ComponentInstaller\ComponentInstaller->onPostPackageInstall() at phar://...build/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:206
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar://...build/bin/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:148
 Composer\EventDispatcher\EventDispatcher->dispatchPackageEvent() at phar://...build/bin/composer.phar/src/Composer/Installer/InstallationManager.php:396
 Composer\Installer\InstallationManager::Composer\Installer\{closure}() at phar://...build/bin/composer.phar/src/Composer/Installer/InstallationManager.php:411
 Composer\Installer\InstallationManager->executeBatch() at phar://...build/bin/composer.phar/src/Composer/Installer/InstallationManager.php:319
 Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar://...build/bin/composer.phar/src/Composer/Installer/InstallationManager.php:218
 Composer\Installer\InstallationManager->execute() at phar://...build/bin/composer.phar/src/Composer/Installer.php:797
 Composer\Installer->doInstall() at phar://...build/bin/composer.phar/src/Composer/Installer.php:289
 Composer\Installer->run() at phar://...build/bin/composer.phar/src/Composer/Command/InstallCommand.php:146
 Composer\Command\InstallCommand->execute() at phar://...build/bin/composer.phar/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar://...build/bin/composer.phar/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at phar://...build/bin/composer.phar/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar://...build/bin/composer.phar/src/Composer/Console/Application.php:378
 Composer\Console\Application->doRun() at phar://...build/bin/composer.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar://...build/bin/composer.phar/src/Composer/Console/Application.php:141
 Composer\Console\Application->run() at phar://...build/bin/composer.phar/bin/composer:88
 require() at ...build/bin/composer.phar:29

How to reproduce

add laminas/laminas-mvc-form and laminas/laminas-component-installer to the composer.json, then run composer install

Expected behavior

no TypeError

Xerkus commented 1 year ago

Type error is introduced by a BC breaking bugfix in composer released as 2.5.6. \Composer\Installer\InstallationManager::getInstallPath() return type is now nullable. See https://github.com/composer/composer/pull/11455 and https://github.com/composer/composer/issues/11389

Xerkus commented 1 year ago

This might be more than just a type error. It looks like empty string return for install path was not properly handled before either. metapackages normally don't define extras so it went unnoticed.

Xerkus commented 1 year ago

@mimmi20 Thank you for the report. You will need to bump this component to v3 for this fix.