markshust / docker-magento

Mark Shust's Docker Configuration for Magento
https://m.academy/courses/set-up-magento-2-development-environment-docker/
MIT License
2.54k stars 997 forks source link

Latest Composer is incompatible with latest Magento #1084

Closed nanderson11 closed 6 months ago

nanderson11 commented 6 months ago

Description When setting docker-magento up for the first time, it installs the latest version of Composer from what I see here https://github.com/markshust/docker-magento/blob/69f29dea57f12e8f7363e483b753a299d15cb030/images/php/8.2/Dockerfile#L95. Currently, this installs Composer 2.7.1. After setup, if I run bin/composer (without arguments), it outputs an error (below). This seems to be caused by the issue discussed here https://github.com/composer/composer/issues/11843, caused by an incompatibility with Composer 2.7+ and Magento.

Expected Result I think it would be nice if instead of installing the latest version of Composer, it installed the latest version of Composer that's compatible with Magento as outlined here: https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/system-requirements.html. I know that you can technically install different versions of Magento in docker-magento though, so maybe it just defaults to whatever version of Composer is compatible with the default version of Magento that's installed.

Actual Result

~/magento.test$ bin/composer
Fatal error: Declaration of Magento\ComposerRootUpdatePlugin\Plugin\Commands\OverrideRequireCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output) must be compatible with Composer\Command\RequireCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int in /var/www/html/vendor/magento/composer-root-update-plugin/Plugin/Commands/OverrideRequireCommand.php on line 173
markshust commented 6 months ago

Great catch -- it should definitely be pegged to the supported version of Composer for the most recent version, which at this time is 2.2.

YevhenZvieriev commented 6 months ago

I pegged the version of Composer for 2.2.0 for PHP 8.2

Should I do this for 8.1 and 8.3?

YevhenZvieriev commented 6 months ago

Hi, @markshust

The official system requirements for Magento 2.4.5 state that Composer 2.2 is supported.

However, Composer 2.2.0 throws the error

Fatal error: Uncaught Error: Class "Magento\Framework\Component\ComponentRegistrar" not found in /var/www/html/setup/src/Magento/Setup/registration.php:9

during composer commands.

Screenshot_2024-03-16_00-51-58

This bug has been fixed in later versions of Composer 2.2.

So, we should peg Composer for the 2.2.18 instead of the 2.2.0 version to resolve this issue.

markshust commented 6 months ago

Fixed in https://github.com/markshust/docker-magento/pull/1090. I'll tag new versions and recompile very shortly.