1

I am upgrading my Magento 2.1.9 to 2.2.7 using these following commands

composer require magento/product-community-edition 2.2.7 --no-update
composer update

Then when i'm doing php bin/magento setup:upgrade, i am getting this

Updating modules:
Area code not set: Area code must be set before starting a session.


  [Magento\Framework\Exception\SessionException]                       
  Area code not set: Area code must be set before starting a session.  


Exception trace:
 () at /home/don/Web/fabelio22/vendor/magento/framework/Session/SessionManager.php:175
 Magento\Framework\Session\SessionManager->start() at /home/don/Web/fabelio22/generated/code/Magento/Framework/Session/Generic/Interceptor.php:50
 Magento\Framework\Session\Generic\Interceptor->start() at /home/don/Web/fabelio22/vendor/magento/framework/Session/SessionManager.php:130
 Magento\Framework\Session\SessionManager->__construct() at /home/don/Web/fabelio22/generated/code/Magento/Framework/Session/Generic/Interceptor.php:14
 Magento\Framework\Session\Generic\Interceptor->__construct() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/generated/code/Magento/Framework/Session/Generic/Proxy.php:84
 Magento\Framework\Session\Generic\Proxy->_getSubject() at /home/don/Web/fabelio22/generated/code/Magento/Framework/Session/Generic/Proxy.php:207
 Magento\Framework\Session\Generic\Proxy->getSessionIdForHost() at /home/don/Web/fabelio22/vendor/magento/framework/Url.php:981
 Magento\Framework\Url->_prepareSessionUrl() at /home/don/Web/fabelio22/vendor/magento/framework/Url.php:949
 Magento\Framework\Url->createUrl() at /home/don/Web/fabelio22/vendor/magento/framework/Url.php:876
 Magento\Framework\Url->getUrl() at /home/don/Web/fabelio22/vendor/magento/module-ui/Config/Argument/Parser/Url.php:52
 Magento\Ui\Config\Argument\Parser\Url->evaluate() at /home/don/Web/fabelio22/vendor/magento/framework/Data/Argument/Interpreter/Composite.php:61
 Magento\Framework\Data\Argument\Interpreter\Composite->evaluate() at /home/don/Web/fabelio22/vendor/magento/framework/Data/Argument/Interpreter/ArrayType.php:44
 Magento\Framework\Data\Argument\Interpreter\ArrayType->evaluate() at /home/don/Web/fabelio22/generated/code/Magento/Framework/Data/Argument/InterpreterInterface/Proxy.php:95
 Magento\Framework\Data\Argument\InterpreterInterface\Proxy->evaluate() at /home/don/Web/fabelio22/vendor/magento/framework/Data/Argument/Interpreter/Composite.php:61
 Magento\Framework\Data\Argument\Interpreter\Composite->evaluate() at /home/don/Web/fabelio22/vendor/magento/framework/Data/Argument/Interpreter/ArrayType.php:44
 Magento\Framework\Data\Argument\Interpreter\ArrayType->evaluate() at /home/don/Web/fabelio22/generated/code/Magento/Framework/Data/Argument/InterpreterInterface/Proxy.php:95
 Magento\Framework\Data\Argument\InterpreterInterface\Proxy->evaluate() at /home/don/Web/fabelio22/vendor/magento/framework/Data/Argument/Interpreter/Composite.php:61
 Magento\Framework\Data\Argument\Interpreter\Composite->evaluate() at /home/don/Web/fabelio22/vendor/magento/module-ui/Config/Reader/Definition/Data.php:147
 Magento\Ui\Config\Reader\Definition\Data->evaluateComponentArguments() at /home/don/Web/fabelio22/vendor/magento/module-ui/Config/Reader/Definition/Data.php:102
 Magento\Ui\Config\Reader\Definition\Data->initData() at /home/don/Web/fabelio22/vendor/magento/module-ui/Config/Reader/Definition/Data.php:81
 Magento\Ui\Config\Reader\Definition\Data->__construct() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:180
 Magento\Framework\ObjectManager\Factory\AbstractFactory->parseArray() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:156
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:56
 Magento\Framework\ObjectManager\ObjectManager->create() at /home/don/Web/fabelio22/vendor/magento/framework/View/LayoutFactory.php:50
 Magento\Framework\View\LayoutFactory->create() at /home/don/Web/fabelio22/vendor/magento/module-payment/Helper/Data.php:79
 Magento\Payment\Helper\Data->__construct() at /home/don/Web/fabelio22/generated/code/Magento/Payment/Helper/Data/Interceptor.php:14
 Magento\Payment\Helper\Data\Interceptor->__construct() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:180
 Magento\Framework\ObjectManager\Factory\AbstractFactory->parseArray() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:156
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /home/don/Web/fabelio22/vendor/magento/framework/ObjectManager/ObjectManager.php:56
 Magento\Framework\ObjectManager\ObjectManager->create() at /home/don/Web/fabelio22/vendor/magento/framework/Console/Cli.php:135
 Magento\Framework\Console\Cli->getApplicationCommands() at /home/don/Web/fabelio22/vendor/magento/framework/Console/Cli.php:116
 Magento\Framework\Console\Cli->getDefaultCommands() at /home/don/Web/fabelio22/vendor/symfony/console/Application.php:1140
 Symfony\Component\Console\Application->init() at /home/don/Web/fabelio22/vendor/symfony/console/Application.php:495
 Symfony\Component\Console\Application->find() at /home/don/Web/fabelio22/vendor/symfony/console/Application.php:182
 Symfony\Component\Console\Application->doRun() at /home/don/Web/fabelio22/vendor/magento/framework/Console/Cli.php:102
 Magento\Framework\Console\Cli->doRun() at /home/don/Web/fabelio22/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at /home/don/Web/fabelio22/bin/magento:23

can someone help me on what to look at. Thank you!

  • try deleting the contents of generated/code. – Marius Jan 11 at 9:24
  • thanks for replying, but nope it's still error – Doni Wibowo Jan 11 at 9:26
  • it seems that some modules are not compatible with 2.2, and I am working to enable the module one by one to find one which one caused it. – Doni Wibowo Jan 14 at 15:09
  • I found what cause the issue. Some custom modules inject their classes using \Magento\Sales\Api\Data\OrderInterface OR \Magento\Sales\Api\OrderManagementInterface, and because of DI chain, it ends up instantiating Magento\Payment\Helper\Data and causing above issue – Doni Wibowo Jan 15 at 4:31
1

Apparently, in Magento 2.2 there is a new UI config reader definition classes that later instantiate sessionManager. So, injecting these following classes in Console Command Class constructors:

\Magento\Sales\Api\Data\OrderInterface
\Magento\Sales\Api\OrderManagementInterface

will run through the DI chain and later will instantiate sessionManager and sessionManager requires area code to be set. While the Console command classes don't have area code set hence the error thrown.

Since I couldn't find anywhere the Magento way to do this, my solution is remove the injections and use objectManager only for Console classes. I know it's not best practice, but at least we can upgrade to 2.2 now.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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