PackageVersions: Error when using Composer 1.6.4 with PHP 7.0

Running composer update ends with the following error

PHP Fatal error:  Uncaught TypeError: Return value of PackageVersions\Installer::activate() must be an instance of PackageVersions\void, none returned in /var/www/php/vendor/ocramius/package-versions/src/PackageVersions/Installer.php:62
Stack trace:
#0 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(236): PackageVersions\Installer->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
#1 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(PackageVersions\Installer))
#2 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#3 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#4 phar:///usr/local/bin/composer/src/Composer/Factory.php(384): Composer\Plugin\PluginManager->loadInstalledPlugins( in /var/www/php/vendor/ocramius/package-versions/src/PackageVersions/Installer.php on line 62

Fatal error: Uncaught TypeError: Return value of PackageVersions\Installer::activate() must be an instance of PackageVersions\void, none returned in /var/www/php/vendor/ocramius/package-versions/src/PackageVersions/Installer.php:62
Stack trace:
#0 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(236): PackageVersions\Installer->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
#1 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(PackageVersions\Installer))
#2 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#3 phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#4 phar:///usr/local/bin/composer/src/Composer/Factory.php(384): Composer\Plugin\PluginManager->loadInstalledPlugins( in /var/www/php/vendor/ocramius/package-versions/src/PackageVersions/Installer.php on line 62

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 27 (13 by maintainers)

Commits related to this issue

Most upvoted comments

That should already be the case: vendor should be installed, not copied, as that guarantees that dependencies do work on different machines

Not sure if it’s for you or composer team, but updating composer from 1.6.3 to 1.6.4 now broke the build because of the :void return type. Cannot see anywhere on the composer’s website that PHP 7.0 is not supported.

Thanks

The only solution (for now) is “don’t share vendor folder between machines”.

You should share vendor/ that is installed according to your lowest required PHP version, otherwise it’s not portable. It should be enforced it by using config.platform.php in composer.json.

No, the plugin is on your system, not in phar:// (contents of composer.phar).

The path of this plugin is /var/www/php/vendor/ocramius/package-versions/src/PackageVersions/Installer.php in your case.

The problem here is that the PackageVersions plugin is installed in the project you currently have open (or as global dependency somewhere), and you try running it against 7.0.

You are running it on PHP 7.0.* instead of 7.1+