9

I have been trying to get around this Area code not set error and have references the others in here, but have a issue tracking it down.

i have been trying to upgrade 2.0.7 to 2.1.0 and when i get to the point where i run:

php bin/magento setup:upgrade -vvv

I get this as the error.

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

Exception trace: () at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Session/SessionManager.php:176 Magento\Framework\Session\SessionManager->start() at /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Session/Generic/Interceptor.php:50 Magento\Framework\Session\Generic\Interceptor->start() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Session/SessionManager.php:130 Magento\Framework\Session\SessionManager->__construct() at /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Session/Generic/Interceptor.php:14 Magento\Framework\Session\Generic\Interceptor->__construct() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:93 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:89 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/app/code/J2t/Rewardpoints/Observer/ProcessSaveModel.php:21 J2t\Rewardpoints\Observer\ProcessSaveModel->execute() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php:73 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php:61 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Manager.php:66 Magento\Framework\Event\Manager->dispatch() at /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Event/Manager/Proxy.php:95 Magento\Framework\Event\Manager\Proxy->dispatch() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/AbstractModel.php:800 Magento\Framework\Model\AbstractModel->afterSave() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:818 Magento\Framework\Model\ResourceModel\Db\AbstractDb->processAfterSaves() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:408 Magento\Framework\Model\ResourceModel\Db\AbstractDb->save() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/AbstractModel.php:631 Magento\Framework\Model\AbstractModel->save() at /opt/bitnami/apps/magento/htdocs/vendor/magento/module-indexer/Setup/Recurring.php:108 Magento\Indexer\Setup\Recurring->install() at /opt/bitnami/apps/magento/htdocs/setup/src/Magento/Setup/Model/Installer.php:871 Magento\Setup\Model\Installer->handleDBSchemaData() at /opt/bitnami/apps/magento/htdocs/setup/src/Magento/Setup/Model/Installer.php:779 Magento\Setup\Model\Installer->installSchema() at /opt/bitnami/apps/magento/htdocs/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php:89 Magento\Setup\Console\Command\UpgradeCommand->execute() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257 Symfony\Component\Console\Command\Command->run() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Application.php:874 Symfony\Component\Console\Application->doRunCommand() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Application.php:195 Symfony\Component\Console\Application->doRun() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Console/Cli.php:96 Magento\Framework\Console\Cli->doRun() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Application.php:126 Symfony\Component\Console\Application->run() at /opt/bitnami/apps/magento/htdocs/bin/magento:23

[Magento\Framework\Exception\LocalizedException] Area code is not set

Exception trace: () at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/State.php:139 Magento\Framework\App\State->getAreaCode() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Session/SessionManager.php:174 Magento\Framework\Session\SessionManager->start() at /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Session/Generic/Interceptor.php:50 Magento\Framework\Session\Generic\Interceptor->start() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Session/SessionManager.php:130 Magento\Framework\Session\SessionManager->__construct() at /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Session/Generic/Interceptor.php:14 Magento\Framework\Session\Generic\Interceptor->__construct() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:93 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:89 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:126 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:53 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:82 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/ObjectManager/ObjectManager.php:71 Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/app/code/J2t/Rewardpoints/Observer/ProcessSaveModel.php:21 J2t\Rewardpoints\Observer\ProcessSaveModel->execute() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php:73 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Invoker/InvokerDefault.php:61 Magento\Framework\Event\Invoker\InvokerDefault->dispatch() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Event/Manager.php:66 Magento\Framework\Event\Manager->dispatch() at /opt/bitnami/apps/magento/htdocs/var/generation/Magento/Framework/Event/Manager/Proxy.php:95 Magento\Framework\Event\Manager\Proxy->dispatch() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/AbstractModel.php:800 Magento\Framework\Model\AbstractModel->afterSave() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:818 Magento\Framework\Model\ResourceModel\Db\AbstractDb->processAfterSaves() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php:408 Magento\Framework\Model\ResourceModel\Db\AbstractDb->save() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Model/AbstractModel.php:631 Magento\Framework\Model\AbstractModel->save() at /opt/bitnami/apps/magento/htdocs/vendor/magento/module-indexer/Setup/Recurring.php:108 Magento\Indexer\Setup\Recurring->install() at /opt/bitnami/apps/magento/htdocs/setup/src/Magento/Setup/Model/Installer.php:871 Magento\Setup\Model\Installer->handleDBSchemaData() at /opt/bitnami/apps/magento/htdocs/setup/src/Magento/Setup/Model/Installer.php:779 Magento\Setup\Model\Installer->installSchema() at /opt/bitnami/apps/magento/htdocs/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php:89 Magento\Setup\Console\Command\UpgradeCommand->execute() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257 Symfony\Component\Console\Command\Command->run() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Application.php:874 Symfony\Component\Console\Application->doRunCommand() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Application.php:195 Symfony\Component\Console\Application->doRun() at /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Console/Cli.php:96 Magento\Framework\Console\Cli->doRun() at /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Symfony/Component/Console/Application.php:126 Symfony\Component\Console\Application->run() at /opt/bitnami/apps/magento/htdocs/bin/magento:23

setup:upgrade [--keep-generated] [--magento-init-params="..."]

So if anyone can assist with where to look, this would be great

Thanks in advance

  • Take a look here first: magento-quickies.alanstorm.com/post/142652104930/… I don't know if this will work for you, as in the case described he was making a customer CLI module. Also, looking through your stack trace, i don't see any 3rd party modules. Are you using any? Those are the next trigger for this kind of error. That was what I ran into a few weeks back: magento.stackexchange.com/questions/128658/… – circlesix Aug 25 '16 at 0:43
  • 1
    there are, two, so I will back them out and see where this goes. – David Aschenbrener Aug 25 '16 at 16:04
  • Something else that popped in to my head, make sure you are clearing the folders in /var as you test. If a error is kicking in the var/generation, even if you fix the issue in the code, this folder is looked to when you perform any other CLI commands, and can trip you up as you go. – circlesix Aug 25 '16 at 16:28
  • forsure did that, so what i did end up doing is disabling the J2t module, and run again. – David Aschenbrener Aug 25 '16 at 16:34
  • I ran into a small error But when Magento try to update "Magento_Cms" native extension, I got a : The page URL key contains capital letters or disallowed symbols. but following this magento.stackexchange.com/questions/123364/… fixed it and shazaam, i am upgraded. – David Aschenbrener Aug 25 '16 at 16:34
5

Take a look here:

Magento\Framework\ObjectManager\ObjectManager->get() at /opt/bitnami/apps/magento/htdocs/app/code/J2t/Rewardpoints/Observer/ProcessSaveModel.php:21

Looks like this module is trying to grab the Object Manager which might be triggering the error if that area code is not set. In my comment, i linked to a solution i found to this error for an extension i was using. Might help you out here as the call to the Object Manager is happening in an Observer.

Here is that link again: Magento 2 "Area code not set" warning in 3rd party module

  • 1
    I have the same problem, but in my case, I don't see any third part modules from the exception trace. All lines from exception trace are Magento\Framework\ObjectManager..... Can I trace more errors from log excep this -vvv option? – Magento Learner Apr 17 '18 at 12:24
  • That's the first place to start. I have seen this issue come up for other reasons outside of this specific question. It would be worth trying to get a more verbose report and then posting a new question. – circlesix Apr 17 '18 at 14:35
2

I just experienced this issue running bin/magento setup:upgrade, and the exception was thrown by module-config.

Area code is not set {"exception":"[object] (Magento\\Framework\\Exception\\State\\InvalidTransitionException(code: 0): Area code is not set at /magento/htdocs/vendor/magento/module-config/Model/Config/Importer.php:137

It turned out that I had some settings in app/etc/env.php that the configuration importer did not like. Setting a breakpoint on that line showed me which data was trying to be updated, and removing that from app/etc/env.php fixed the issue for me.

Hope this helps someone!

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.