Skip to content

[4.x]: Composer 2.2.15 #12482

Closed
Closed
@ishetnogferre

Description

@ishetnogferre

What happened?

Description

Starting today in every Craft 3.4.5 project where we have removed the composer.lock and vendor folder and then after reinstalling the composer packages and trying to install or update any Craft plugin, it get's interrupted with following error:

Screenshot 2022-12-22 at 20 57 37

Error: count(): Argument #1 ($value) must be of type Countable|array, Closure given

Composer output: Loading composer repositories with package information
Updating dependencies

When looking at the web.log file we found following stack:

2022-12-22 19:06:11 [web.ERROR] [TypeError] TypeError: count(): Argument #1 ($value) must be of type Countable|array, Closure given in /Users/****/vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php:1202
Stack trace:
#0 /Users/****/vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php(1202): count(Object(Closure))
#1 /Users/****/vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php(412): Composer\Autoload\AutoloadGenerator->getStaticFile('ec23c9847411143...', '/Users/...', '/Users/...', '/Users/...', 50600)
#2 /Users/****//vendor/composer/composer/src/Composer/Installer.php(341): Composer\Autoload\AutoloadGenerator->dump(Object(Composer\Config), Object(Composer\Repository\InstalledFilesystemRepository), Object(Composer\Package\RootPackage), Object(Composer\Installer\InstallationManager), '/Users/****/...', false)
#3 /Users/****/vendor/craftcms/cms/src/services/Composer.php(583): Composer\Installer->run()
#4 /Users/****/vendor/craftcms/cms/src/services/Composer.php(190): craft\services\Composer->run(Object(Composer\Installer))
#5 /Users/****//vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(174): craft\services\Composer->install(Array, Object(Composer\IO\BufferIO))
#6 [internal function]: craft\controllers\BaseUpdaterController->actionComposerInstall()
#7 /Users/****/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#8 /Users/****/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#9 /Users/****/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('composer-instal...', Array)
#10 /Users/****/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('pluginstore/ins...', Array)
#11 /Users/****//vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('pluginstore/ins...', Array)
#12 /Users/****/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#13 /Users/****//vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#14 /Users/****//web/index.php(15): yii\base\Application->run()
#15 /Users/****//.composer/vendor/laravel/valet/server.php(235): require('/Users/****/...')
#16 {main} {"memory":11950200,"exception":"[object] (TypeError(code: 0): count(): Argument #1 ($value) must be of type Countable|array, Closure given at /Users/****//vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php:1202)"} 
2022-12-22 19:06:11 [web.INFO] [application] Request context:
$_GET = [
    'p' => 'admin/actions/pluginstore/install/composer-install'
    'v' => '1671735964331'
]

The errors and the location of it led me to this issue on the composer repo:
composer/composer#11234

I'm afraid I don't really understand that much of what is described here, but if I understand it correctly, either we have to downgrade our own composer version or have the Craft CMS one upgraded?

Craft CMS version

3.4.5

PHP version

8.1 & 8.2

Operating system and version

MacOS13

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Composer version 2.5.0

Activity

ishetnogferre

ishetnogferre commented on Dec 23, 2022

@ishetnogferre
Author

Locally or in ddev changing the composer version to either 2.4.4 or 2.5.1 has fixed it for now

brandonkelly

brandonkelly commented on Dec 24, 2022

@brandonkelly
Member

Craft explicitly requires Composer 2.2.15 for its internal Composer operations:

"composer/composer": "2.2.15",

We do that because there were breaking changes introduced in 2.3. Why and how are you on a different version?

ishetnogferre

ishetnogferre commented on Dec 27, 2022

@ishetnogferre
Author

@brandonkelly the composer in the vendor folder is indeed 2.2.15.

My local composer version and the one in ddev (for the command line) was 2.5.0 and somehow this setup seems to give the above count error.

brianjhanson

brianjhanson commented on Dec 27, 2022

@brianjhanson
Contributor

I'm going to close this one out because upgrading/downgrading composer is the best fix at the moment. It looks like the original issue you linked to confirms there are some issues when running in a setup like ours. Hopefully, we can work through the breaking changes and get the internal version of composer updated, which should solve this.

brandonkelly

brandonkelly commented on Dec 28, 2022

@brandonkelly
Member

Ah I get it, it’s an issue that comes up when using Craft’s built-in copy of Composer with autoload files that were generated by Composer 2.5.

brandonkelly

brandonkelly commented on Dec 31, 2022

@brandonkelly
Member

Looks like the issue has been fixed for the next Composer 2.2 release, so we’ll keep an eye out for that.

mortendk

mortendk commented on Jan 18, 2023

@mortendk

For DDEV i did a ddev composer self-update and voila im up and running again

added a commit that references this issue on Feb 7, 2023
89fe066
brandonkelly

brandonkelly commented on Feb 7, 2023

@brandonkelly
Member

Composer 2.2.19 was released a couple days ago, which includes the fix for this.

We just released Craft 3.7.65 and 4.3.8 with that Composer update, so this should be fixed going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @brandonkelly@mortendk@brianjhanson@ishetnogferre

        Issue actions

          [4.x]: Composer 2.2.15 · Issue #12482 · craftcms/cms