Magento 2 upgrade from 2.2.3 to 2.2.4 or 2.2.5 causes Area code is not set while executing bin/magento setup:upgrade

On by

less than 1 minute read

While upgrading magento db schema bin/magento setup:upgrade from 2.2.3 to 2.2.5 I ended up with magento throwing general error like this.

Module 'Magento_Directory':
Upgrading data..
Area code is not set

Even with verbose mode bin/magento -vvv setup:upgrade it would’t tell me exact error.

Upgrading data..
Area code is not set

So Magento was hiding something from me. After losing some time I desperately tried using swiss army knife for Magento developers, and here it was. Using magerun in verbose mode showed me backtrace of error.

n98-magerun2 -vvv setup:upgrade

My favorite method for intalling magerun is directly to ‘/usr/sbin’

wget -O /usr/sbin/n98-magerun2
chmod +x /usr/sbin/n98-magerun2

More information about MageRun2 for Magento 2 can be found on GitHub. There is also a version for Magento 1 also available on GitHub.