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.. [Magento\Framework\Exception\LocalizedException] 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 https://files.magerun.net/n98-magerun2.phar chmod +x /usr/sbin/n98-magerun2