Civi incompatible with composer 2.5 (serialization of closure is not allowed)
In https://github.com/composer/composer/commit/39de9899a70d8351db134027dc24ed35fc629346#diff-2f0f90552ea46ccb1d7d485298d70262be6825e776fa8e35de15f2f6c4e3efedR114 they added a closure to composer's classloader.
In civi, it creates a cache of the extension classloader (which extends composer's) by serializing it: https://github.com/civicrm/civicrm-core/blob/04edd1c101b3d4982c727aae083f7f92c8440928/CRM/Extension/ClassLoader.php#L85
You can't serialize closures, so it gives an error.
Note to reproduce this when using cv
, you'll need to build cv from source using composer 2.5, since when using cv it uses its own vendor's copy of the composer classloader, not the one in the civi install's vendor folder. So the one in cv might be an older one if using a phar, and then you won't see the error.