Composer 2.3.0 breaks Symfony 3.4 app

If you experience the following error while installing the required packages for Symfony 3.4 packages, it is highly possible to have Composer 2.3.0 or newer installed:

symfony-scripts: Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap

In Process.php line 143:

[TypeError]
Argument 1 passed to Symfony\Component\Process\Process::__construct() must
be of the type array, string given, called in /var/www/example.com/releases/20220330124916/vendor/sensio/distribution-bundle/Composer/Scrip
tHandler.php on line 310

The root cause of the issue is that Composer 2.3.x requires symfony/process^5 itself, but your project also has a dependency on symfony/process^4 somewhere, composer loads it first and when your project tries to use it, expecting v4 but using v5 instead it triggers the error

The quick and dirty solution is to downgrade Composer to 2.2.x so you are able to update your dependencies normally. To do that just run the following command

sudo composer self-update 2.2.9

Enjoy!