Magento 2.1.18 is the final 2.1.x release. After June 2019, Magento 2.1.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Errors installing optional sample data

This topic discusses solutions to errors you might encounter installing optional sample data.

Symptom (file system permissions)

Error in the console log during sample data installation using the Setup Wizard:

1
2
3
4
5
6
7
8
Module 'Magento_CatalogRuleSampleData':
[ERROR] exception 'Magento\Framework\Exception\LocalizedException' with message 'Can't create directory /var/www/html/magento2/var/generation/Magento/CatalogRule/Model/.' in /var/www/html/magento2/lib/internal/Magento/Framework/Code/Generator.php:103

(more)

Next exception 'ReflectionException' with message 'Class Magento\CatalogRule\Model\RuleFactory does not exist' in /var/www/html/magento2/lib/internal/Magento/Framework/Code/Reader/ClassReader.php:29

(more)

These exceptions result from file system permissions settings.

Solution

Set file system ownership and permissions again as a user with root privileges.

Symptom (production mode)

If you’re currently set for production mode, sample data installation fails if you use the magento sampledata:deploy command:

1
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Console\Input\ArrayInput::__construct() must be of the type array, object given, called in /<path>/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 97 and defined in /<path>/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php:37

Solution

Don’t install sample data in production mode. Switch to developer mode and clear some var directories and try again.

Enter the following commands in the order shown as the Magento file system owner:

1
2
3
4
cd <magento_root>
bin/magento deploy:mode:set developer
rm -rf var/generation/* var/di/*
bin/magento sampledata:deploy

Symptom (security)

During installation of optional sample data, a message similar to the following displays:

1
PHP Fatal error: Call to undefined method Magento\Catalog\Model\Resource\Product\Interceptor::getWriteConnection() in /var/www/magento2/app/code/Magento/SampleData/Module/Catalog/Setup/Product/Gallery.php on line 144

Solution

During sample data installation, disable SELinux using a resource such as:

Symptom (develop branch)

Other errors display, such as:

1
[Magento\Setup\SampleDataException] Error during sample data installation: Class Magento\Sales\Model\Service\OrderFactory does not exist

Solution

There are known issues with using sample data with the Magento 2 develop branch. Use the master branch instead. You can switch to the master branch as follows:

1
2
3
cd <magento_root>
git checkout master
git pull origin master

Symptom (max_execution_time)

The installation stops before the sample data installation finishes. An example follows:

1
2
3
4
(more)

Module 'Magento_CustomerSampleData':
Installing data...

Sample data installation does not finish.

This error occurs when the maximum configured execution time of your PHP scripts is exceeded. Because sample data can take a long time to load, you can increase the value during your installation.

Solution

As a user with root privileges, modify php.ini to increase the value of max_execution_time to 600 or more. (600 seconds is 10 minutes. You can increase the value to whatever you want.) You should change max_execution_time back to its previous value after the installation is successful.

If you’re not sure where php.ini is located, enter the following command:

1
php --ini

The value of Loaded Configuration File is the php.ini you must modify.

Updated