21

I have just run a composer update on my Magento 2.4.2-p1 installation and now I cant compile it, I am getting the following error

    Errors during compilation:
        Magento\Framework\Setup\Option\AbstractConfigOption
                Incompatible argument type: Required type: int. Actual type: string; File: 
/var/www/vhosts/mydomain.co.uk/httpdocs/vendor/magento/framework/Setup/Option/AbstractConfigOption.php

Total Errors Count: 1

In Log.php line 92:
                            
  Error during compilation

The updated modules are

  • Upgrading aws/aws-sdk-php (3.185.20 => 3.185.21)
  • Upgrading mageplaza/magento-2-english-united-kingdom-language-pack (dev-master 8e27b82 => dev-master 83b40fa)
  • Upgrading symfony/config (v5.3.3 => v5.3.4)
  • Upgrading symfony/console (v4.4.26 => v4.4.27)
  • Upgrading symfony/css-selector (v5.3.0 => v5.3.4)
  • Upgrading symfony/dependency-injection (v5.3.3 => v5.3.4)
  • Upgrading symfony/event-dispatcher (v4.4.25 => v4.4.27)
  • Upgrading symfony/filesystem (v5.3.3 => v5.3.4)
  • Upgrading symfony/finder (v5.3.0 => v5.3.4)
  • Upgrading symfony/http-foundation (v5.3.3 => v5.3.4)
  • Upgrading symfony/mime (v5.3.2 => v5.3.4)
  • Upgrading symfony/options-resolver (v5.3.0 => v5.3.4)
  • Upgrading symfony/process (v4.4.26 => v4.4.27)
  • Upgrading symfony/property-access (v5.3.0 => v5.3.4)
  • Upgrading symfony/property-info (v5.3.1 => v5.3.4)
  • Upgrading symfony/stopwatch (v5.3.0 => v5.3.4)
  • Upgrading symfony/yaml (v5.3.3 => v5.3.4)

Does anyone have an idea whats causing the error?

7 Answers 7

17

Since approx. 2hrs there is a pull request for symfony/console. This will fix that issue.

https://github.com/symfony/console/pull/75

3
  • That PR is just a change to a docblock though?
    – eddhall
    Jul 27, 2021 at 20:12
  • Well hey what do you know, it works!
    – eddhall
    Jul 27, 2021 at 20:44
  • symfony/console 4.4.29 was published. This contians the fix. Jul 29, 2021 at 10:16
14

I had the same problem tonight. I did a trace to find out which module is causing the problem. I had to downgrade symfony/console to get it to compile.

composer require symfony/console=4.4.26

After you have downgraded symfony/console, you will need to run the Magento 2 upgrade script to make sure you are compiling the new module.

php bin/magento setup:upgrade
php bin/magento setup:di:compile

This is the error generated in the log when trying to compile Magento 2 using symfony/console 4.4.27...

Interception cache generation... 6/9 [==================>---------]  66% 31 secs 498.0 MiBErrors during compilation:
    Magento\Framework\Setup\Option\AbstractConfigOption
        Incompatible argument type: Required type: int. Actual type: string; File: 
/var/www/html/magento2/vendor/magento/framework/Setup/Option/AbstractConfigOption.php

Total Errors Count: 1

In Log.php line 92:
                                           
  [Magento\Framework\Validator\Exception]  
  Error during compilation                 
                                           

Exception trace:
  at /var/www/html/magento2/setup/src/Magento/Setup/Module/Di/Compiler/Log/Log.php:92
 Magento\Setup\Module\Di\Compiler\Log\Log->report() at /var/www/html/magento2/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Interceptions.php:85
 Magento\Setup\Module\Di\Code\Reader\Decorator\Interceptions->getList() at /var/www/html/magento2/setup/src/Magento/Setup/Module/Di/App/Task/Operation/InterceptionCache.php:59
 Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache->doOperation() at /var/www/html/magento2/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
 Magento\Setup\Module\Di\App\Task\Manager->process() at /var/www/html/magento2/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:216
 Magento\Setup\Console\Command\DiCompileCommand->execute() at /var/www/html/magento2/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/html/magento2/vendor/symfony/console/Application.php:1009
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/magento2/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /var/www/html/magento2/vendor/magento/framework/Console/Cli.php:115
 Magento\Framework\Console\Cli->doRun() at /var/www/html/magento2/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /var/www/html/magento2/bin/magento:23
9
  • Hello @chris the downgrade doesn't work for me. Any idea? Jul 27, 2021 at 10:59
  • 1
    Hi @michelangelo. You need to run "php bin/magento setup:upgrade" first before running "setup:di:compile", otherwise you are just recompiling the old Magento modules. Jul 28, 2021 at 10:13
  • 1
    This is the answer.
    – andy jones
    Jul 28, 2021 at 14:45
  • Hi @ChrisPerver I have executed "php bin/magento setup:upgrade" first before running "setup:di:compile" but the result is the same: i.imgur.com/LzzgzJO.png Jul 28, 2021 at 15:26
  • Just put this in your composer.json and run composer update command. It's not a symfony issue, it's Magento not being smart enough to resolve types correctly "conflict": { "symfony/console": ">=v5.3.4||>=v4.4.27" }, Jul 28, 2021 at 19:28
11

A temporary fix that I have done taken backup of vendor/symfony/console/Input/InputOption.php file and modify it.

After line 48 replace the comment as below before constructor:

/**
     * @param string $name
      * @param string|array|null                $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
      * @param int|null                         $mode     The option mode: One of the VALUE_* constants
      * @param string|bool|int|float|array|null $default  The default value (must be null for self::VALUE_NONE)
     *
     * @throws InvalidArgumentException If option mode is invalid or incompatible
     */

I basically added first parameter $name of string type.

2

I faced this issue too, downgrading symfony/console works.

composer require symfony/console=4.4.26
5
  • This solution doesn't work at all. Jul 27, 2021 at 10:55
  • @Michelangelo It did work for me
    – Begoodpy
    Jul 27, 2021 at 14:56
  • Same, works for me, and for a bunch of people per above answers.
    – QuietGeek
    Jul 27, 2021 at 14:58
  • This should be marked as the best answer
    – Rus0
    Jul 27, 2021 at 22:24
  • It is really odd! It doesn't work in my case! Why?! check this screenshot i.imgur.com/zBWTSFU.jpg Jul 28, 2021 at 7:07
0

Downgrading symfony/console works.

In CLI: composer require symfony/console=4.4.26

The error lies in vendor\symfony\console\Input\InputOption.php

The working code from last version, starting on line 50:

/**
 * @param string                    $name        The option name
 * @param string|array|null         $shortcut    The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
 * @param int|null                  $mode        The option mode: One of the VALUE_* constants
 * @param string                    $description A description text
 * @param string|string[]|bool|null $default     The default value (must be null for self::VALUE_NONE)
 *
 * @throws InvalidArgumentException If option mode is invalid or incompatible
 */

Is now incorrect:

/**
 * @param string|array|null                $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
 * @param int|null                         $mode     The option mode: One of the VALUE_* constants
 * @param string|bool|int|float|array|null $default  The default value (must be null for self::VALUE_NONE)
 *
 * @throws InvalidArgumentException If option mode is invalid or incompatible
 */

Restoring this block works, but I recommend downgrading to last version to be safe. There is already a pull request for the newest version on github for symfony/console. This will also fix that issue.

https://github.com/symfony/console/pull/75

0

Downgrading symfony/console works for me : -

Run below command inside the given directory

         /var/www/html/magento2$ - my directory 

               -  composer require symfony/console=4.4.26     
               -  sudo php bin/magento setup:upgrade
                          
          



        
0

This was fixed by the Magento in their repo, so no need for the custom fix. No need to downgrade Symfony also.

https://github.com/symfony/console/pull/75/commits/eae76f1391034d4f8e4f8a6e7e73b3c6258d3b70

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.