Flex: Composer suddenly broken: [UnexpectedValueException] Invalid version string "5.x"

Created on 6 Oct 2020  路  6Comments  路  Source: symfony/flex

About an hour ago, the "composer install" command stopped working.

 composer install -v


  [UnexpectedValueException]    
  Invalid version string "5.x"  

Exception trace:
 () at phar:///usr/local/bin/composer/vendor/composer/semver/src/VersionParser.php:172
 Composer\Semver\VersionParser->normalize() at /app/vendor/symfony/flex/src/Cache.php:39
 Symfony\Flex\Cache->setSymfonyRequire() at /app/vendor/symfony/flex/src/TruncatedComposerRepository.php:34
 Symfony\Flex\TruncatedComposerRepository->setSymfonyRequire() at /app/vendor/symfony/flex/src/Flex.php:126
 Composer\Repository\RepositoryManager->Symfony\Flex\{closure}() at /app/vendor/symfony/flex/src/Flex.php:132
 Symfony\Flex\Flex->activate() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:236
 Composer\Plugin\PluginManager->addPlugin() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:205
 Composer\Plugin\PluginManager->registerPackage() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:261
 Composer\Plugin\PluginManager->loadRepository() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:76
 Composer\Plugin\PluginManager->loadInstalledPlugins() at phar:///usr/local/bin/composer/src/Composer/Factory.php:384
 Composer\Factory->createComposer() at phar:///usr/local/bin/composer/src/Composer/Factory.php:576
 Composer\Factory::create() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:345
 Composer\Console\Application->getComposer() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:458
 Composer\Console\Application->getPluginCommands() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:156
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:104
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:56
 require() at /usr/local/bin/composer:24

When i try to install it without plugins, it's, ofcourse crushed because I have no "flex":

composer install --no-plugins
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> symfony-cmd
sh: symfony-cmd: not found
Script symfony-cmd handling the auto-scripts event returned with error code 127
Script @auto-scripts was called via post-install-cmd

Sombody help me please!

Most helpful comment

I had the same issue, I fixed it by removing the vendor/symfony folder and updating symfony/flex.

All 6 comments

Have the same problem, help is very much appreciated.

On my side composer update symfony/flex fix the issue. The issue was on the 1.4.1 version.

But any composer command we run returns

[UnexpectedValueException]    
  Invalid version string "5.x"  

Exception trace:
 () at phar:///usr/local/bin/composer/vendor/composer/semver/src/VersionParser.php:172
 Composer\Semver\VersionParser->normalize() at /app/vendor/symfony/flex/src/Cache.php:39
 Symfony\Flex\Cache->setSymfonyRequire() at /app/vendor/symfony/flex/src/TruncatedComposerRepository.php:34
 Symfony\Flex\TruncatedComposerRepository->setSymfonyRequire() at /app/vendor/symfony/flex/src/Flex.php:126
 Composer\Repository\RepositoryManager->Symfony\Flex\{closure}() at /app/vendor/symfony/flex/src/Flex.php:132
 Symfony\Flex\Flex->activate() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:236
 Composer\Plugin\PluginManager->addPlugin() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:205
 Composer\Plugin\PluginManager->registerPackage() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:261
 Composer\Plugin\PluginManager->loadRepository() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:76
 Composer\Plugin\PluginManager->loadInstalledPlugins() at phar:///usr/local/bin/composer/src/Composer/Factory.php:384
 Composer\Factory->createComposer() at phar:///usr/local/bin/composer/src/Composer/Factory.php:576
 Composer\Factory::create() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:345
 Composer\Console\Application->getComposer() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:458
 Composer\Console\Application->getPluginCommands() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:156
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:104
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:56
 require() at /usr/local/bin/composer:24

Did you try to remove vendor directory ?

I had the same issue, I fixed it by removing the vendor/symfony folder and updating symfony/flex.

@thomas-aw, @nicobatty thanks you guys!

Was this page helpful?
0 / 5 - 0 ratings