Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento 2 - 'Area code not set:' after adding sample data

So i've gotten magento 2 working all running fine, I've even started on my own theme, but i've tried to install the sample data after I've installed magento. And it has returned 'Area code not set:' in terminal, below is a little run through of my steps.

bin/magento sampledata:deploy     composer update 

Which returns:

Loading composer repositories with package information Updating dependencies (including require-dev)   - Installing magento/module-catalog-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-bundle-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-widget-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-customer-sample-data (100.0.3)     Downloading: 100%             - Installing magento/sample-data-media (100.0.3)     Downloading: 100%             - Installing magento/module-theme-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-cms-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-catalog-rule-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-sales-rule-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-review-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-tax-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-grouped-product-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-downloadable-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-msrp-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-sales-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-product-links-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-configurable-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-wishlist-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-swatches-sample-data (100.0.3)     Downloading: 100%             - Installing magento/module-offline-shipping-sample-data (100.0.3)     Downloading: 100%           Writing lock file Generating autoload files 

I've then run:

bin/magento setup:upgrade 

And i get the following error shown in a screen shot below, i can't seem to find anyone else having the same error online.

terminal window of Area code not set:

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

And now my mage install just isn't working - error returns:

Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory.

Which I can't do because it returns and error, any help would be awesome.

like image 404
andy jones Avatar asked Feb 01 '16 11:02

andy jones


People also ask

What is setup script in Magento 2?

Save. As the name defines: Setup script files used to perform some action on your data or table while installing or upgrading up your module. All the setup scripts files are created under Setup folder which is at path: app/code/Webkul/Test/Setup.

What are the two ways of installation and extension in Magento 2?

As you may know, there are two most popular ways of installing Magento 2 extension manually. The first one is to use COMMAND LINE (recommended) and the second one is to install manually using Magento configuration.


1 Answers

Had the same issue and was able to resolve it.

Try running this command first:

php bin/magento sampledata:reset 

And then re-run:

php bin/magento setup:upgrade 

In case you had a memory exhausted error (which I encountered), try adding -dmemory_limit=6G on your setup:upgrade command.

php -dmemory_limit=6G bin/magento setup:upgrade 
like image 147
Morgy Avatar answered Oct 01 '22 18:10

Morgy