Symfony console fails in multiple official containers that uses the project since v5.2.6

Symfony version(s) affected: symfony/console v5.2.6

Description
Since the 5.2.6 update of symfony/console seems to rely on the intl extension being enabled.
That is not the case with the official php 8 docker images.
Since this update, all projects that uses symfony/console seems to throw an exception when it tries to access the Normalizer.

This is an issue for multiple reasons, one of which is difficult to fix;
Everyone that uses the composer docker image including automated builds and cd/ci pipeline would fail, as during an install and update of a symfony-flex project it has a step to clean the cache folder using clean:cache, which uses the affected code, so the issue is not as simple to enable this extension.

How to reproduce

  • Run a clean:cache for a symfony-flex with the newest 5.2.6 symfony/console.
  • See that it fails due to the extension not being enabled.

Possible Solution
In my opinion, there are multiple approaches to fixing this issue;

  • State in the composer.json and docs that the extension is necessary for symfony/console (which I think is not ideal as that’s somewhat a breaking change)
  • Update the emoji character length counts in another way that would not utilise this extension.
  • Have this feature to be optional, and if the extension is enabled on runtime. If it is – use it, if it’s not then revert to the solution we had before 5.2.6

Additional context
Error as is during a composer update:

Nothing to install or update
Generating optimized autoload files
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  
!!  [critical] Error thrown while running command "--ansi cache:clear". Message: "Class 'Normalizer' not found"
!!  
!!  
!!  Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#107
!!    #message: """
!!      Attempted to load class "Normalizer" from the global namespace.\n
!!      Did you forget a "use" statement?
!!      """
!!    #code: 0
!!    #file: "./vendor/symfony/console/Helper/Helper.php"
!!    #line: 52
!!    trace: {
!!      ./vendor/symfony/console/Helper/Helper.php:52 { …}
!!      ./vendor/symfony/console/Application.php:826 { …}
!!      ./vendor/symfony/console/Application.php:795 { …}
!!      ./vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php:136 { …}
!!      ./vendor/symfony/error-handler/ErrorHandler.php:607 { …}
!!      Symfony\Component\ErrorHandler\ErrorHandler->handleException() {}
!!    }
!!  }
!!  
Script @auto-scripts was called via post-update-cmd

Error during another projects run that relies on the console component hosted inside the default debian php-8 container:

Stack trace:
#0 /project/vendor/symfony/console/Application.php(826): Symfony\Component\Console\Helper\Helper::strlen()
#1 /project/vendor/symfony/console/Application.php(795): Symfony\Component\Console\Application->doRenderThrowable()
#2 /project/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->renderThrowable()
#3 /project/vendor/symfony/console/Application.php(172): Symfony\Component\Console\Application->Symfony\Component\Console\{closure}()```

1 possible answer(s) on “Symfony console fails in multiple official containers that uses the project since v5.2.6

  1. Hi @stof

    You’re absolutely correct, I used a similar composer.json config across all the failing projects.
    I’m having a replace segment that gets rid of unneeded polyfills.

    I should’ve caught this during debugging of this issue, as now it seems pretty obvious, so I must apologise for wasting your time and creating an invalid bug ticket.

    I was confident of just replacing all polyfills previously as I have extensive unit and e2e testing, and I suppose 5.2.6 now makes use of intl-normalizer which wasn’t the case previously.

    Thank you for the quick reply!
    I’m closing this bug as this is not an issue.