composer: Composer 2.2, running composer update uses incorrect composer source file somehow
Hi
This is something weird that I encountered after upgrading to composer 2.2.1
I have 2 different Magento2 projects, they both run the same version of Magento (2.3.7-p2) but have different custom dependencies.
In one project I have no problem using composer 2.2.1, but in the other project, I get this error when I try to run composer update
:
PHP Fatal error: Uncaught Error: Call to undefined method Composer\Installer::setPlatformRequirementFilter() in phar://composer.phar/src/Composer/Command/UpdateCommand.php:239
Stack trace:
#0 phar://composer.phar/vendor/symfony/console/Command/Command.php(245): Composer\Command\UpdateCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 phar://composer.phar/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 phar://composer.phar/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Composer\Command\UpdateCommand), Object(Symfony\Component\Console\Input\A in phar://composer.phar/src/Composer/Command/UpdateCommand.php on line 239
So it can’t find that setPlatformRequirementFilter
method in Composer\Installer
. Which is strange because it exists in the phar file.
Magento2 does come with composer/composer
as dependency as well, which is currently at version 2.0.13 and can’t be updated further for some reason I haven’t looked into yet (in both projects).
That version of composer does not have that setPlatformRequirementFilter
method yet.
So my guess is that while executing composer update
, somehow composer tries to load Composer\Installer
from vendor/composer/composer
instead of from the composer.phar
file. But only on one project and not in the other, which is very strange …
Any ideas?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 25 (14 by maintainers)
@hostep no worries. you threw me off with the composer/composer require because it was in fact not the root cause of the problem, which is why I thought this was a somewhat bogus issue for so long, but glad we figured it out eventually.
Hi, just for information, I was facing the same kind of issue with Magento 2.4.3 and composer 2.2.2 :
composer create --repository=https://repo.magento.com/ magento/project-community-edition m243 2.4.3
composer config repositories.my-repo path my-own-modules/something/
, an error was thrown :After doing
composer self-update --snapshot
, the error disappears.Sorry, I understand the issue has become quite a mess. The steps to reproduce are in: https://github.com/composer/composer/issues/10401#issuecomment-1002136725 Magento comes with a requirement on both
composer/composer
andlaminas/laminas-zendframework-bridge
.The issue is: When I execute a globally installed
composer.phar
file (version 2.2.2), it starts executing code inside the phar, but the moment it loadslaminas/laminas-zendframework-bridge
it starts switching to the source code ofcomposer/composer
which is installed invendor
. Probably due to you guys loading in another autoload file inlaminas/laminas-zendframework-bridge
.What I expect to happen, is when I run a globally installed
composer.phar
file, it executes all the code from that file, and doesn’t suddenly switch to running source code from an installedcomposer/composer
repository that got installed via composer. Which could potentially have a completely different version than the globally installedcomposer.phar
file.Hope this makes it a bit more clear?
Hmm, this might be a bug introduced in https://github.com/laminas/laminas-zendframework-bridge/pull/90 If I
return null;
in thatgetClassLoaderFromVendorDirectory
method that got introduced there, I get rid of this bug here.@boesing, @Ocramius: any ideas? Do you agree this might be a bug in
laminas/laminas-zendframework-bridge
(I’m using version 1.4.1)? Should I open a new issue over there?Update: downgrading
laminas/laminas-zendframework-bridge
to version 1.4.0 solves my issue. So this is either a bug inlaminas/laminas-zendframework-bridge
version 1.4.1 or a bug incomposer/composer
2.2.0+ or a combination of both I think …