sudo php bin/magento setup:upgrade -vvv
Cache cleared successfully
File system cleanup:
PHP Fatal error:  Uncaught Error: Cannot use object of type Closure as array in /var/www/croquenoix/dev/croquenoix/web/setup/src/Magento/Setup/Model/Installer.php:1288
Stack trace:
#0 /var/www/croquenoix/dev/croquenoix/web/setup/src/Magento/Setup/Model/Installer.php(1013): Magento\Setup\Model\Installer->cleanupGeneratedFiles()
#1 /var/www/croquenoix/dev/croquenoix/web/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php(72): Magento\Setup\Model\Installer->updateModulesSequence(false)
#2 /var/www/croquenoix/dev/croquenoix/web/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Magento\Setup\Console\Command\UpgradeCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/croquenoix/dev/croquenoix/web/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 in /var/www/croquenoix/dev/croquenoix/web/setup/src/Magento/Setup/Model/Installer.php on line 1288

The stack trace is not long enough for me to figure where the error really comes from. How can I see a longer stack trace? How can I debug this error?

  • I have the same issue. after upgrading to Magento 2.3.1 and the cause is that there is an extension that is not compatible with Magento 2.3.1 then I disabled it and there it is now fixed. Apr 2, 2019 at 16:05

5 Answers 5


It must be issue in any custom extension, Please try to remove your custom extension and try to install them one by one. It works for me. May be helpful for other.

  • it turns out this was the case. an extension I had recently installed caused this. I removed it and the error went away. after I have upgraded the Magento 2 version to the latest and then was able to reinstall the extension and did not have the error this time. Aug 8, 2018 at 1:14
  • You mean bin/magento module:disable or complete REMOVE using composer remove?
    – snh_nl
    Apr 23, 2019 at 12:00
  • Just disable the modules
    – Jarnail
    May 6, 2019 at 9:55


bin/magento setup:upgrade --keep-generated

Please run below commands :

 1. rm -rf generated/
 2. sudo chmod -R 777 generated/

then run di compile command :

 php bin/magento setup:di:compile

Try this: We recursively delete the folder var/cache and generation/ . In the generation folder, what is created when run the bin/magento setup:di:compile.

sudo rm -rf var/ generation/

Grant the rights to the current directory

sudo chmod -R 0777 .

sudo bin/magento setup:di:compile

sudo bin/magento setup:upgrade
  • Can you explain what it does? It's helpful to know what it is doing before running it, and explanation could help more people learn what to do in similar but not exact situations.
    – camdixon
    Jun 4, 2018 at 21:46
  • Ok, sorry ) one minute . Jun 4, 2018 at 21:50
  1. 1st delete var/cache and generation folders

  2. run command :

     sudo bin/magento setup:upgrade
  3. give full permission to :

    sudo chmod -R 0777 var/ pub/ generation/ 
  4. and run below command :

     sudo bin/magento setup:di:compile

Your Answer

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

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