How to Fix Exceptions During Magento 2 Installation
Another Magento 2 issue that users often report is related to the installation procedure. A variety of exceptions occur, preventing the usual functionality. Below, we shed light on how to solve this problem. More useful tips are available here: Magento 2 Cookbook. If you need to fix exceptions that occur after the installation, check this article: How to fix the inability to write to the generated/code directory in Magento 2.
Issue
If you noticed exceptions displayed during installation, you’ve come to the right place. It is a quite common issue. Magento 2 users have reported a variety of exceptions, trying to install the software.
You may see the following exceptions as well as numerous others:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Module 'Magento_Indexer': Running recurring.. [ERROR] exception 'Exception' with message 'Recoverable Error: Argument 1 passed to Magento\Indexer\Model\Config\Data::__construct() must be an instance of Magento\Framework\Indexer\Config\Reader, instance of Magento\Indexer\Model\Config\Reader given, called in /home/magento2_dev/ public_html/generated/code/Magento/Indexer/Model/Config/Data/Interceptor.php on line 14 and defined in /home/magento2_dev/public_html/ app/code/Magento/Indexer/Model/Config/Data.php on line 22' in /home/magento2_dev/public_html/lib/internal/Magento/Framework/App/ErrorHandler.php:67 Stack trace: #0 /home/magento2_dev/public_html/app/code/Magento/Indexer/Model/Config/Data.php(22): Magento\Framework\App\ErrorHandler->handler(4096, 'Argument 1 pass...', '/home/magento2...', 22, Array) #1 /home/magento2_dev/public_html/generated/code/Magento/Indexer/Model/Config/Data/Interceptor.php(14): Magento\Indexer\Model\Config\Data-> __construct(Object(Magento\Indexer\Model\Config\Reader), Object(Magento\Framework\App\Cache\Type\Config), Object(Magento\Indexer\Model\Resource\Indexer\State\Collection), 'indexer_config') #2 /home/magento2_dev/public_html/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(103): Magento\Indexer\Model\Config\Data\Interceptor->__construct(Object(Magento\Indexer\Model\Config\Reader), Object(Magento\Framework\App\Cache\Type\Config), Object(Magento\Indexer\Model\Resource\Indexer\State\Collection), 'indexer_config') ... more ... |
Solution
Although the issue may seem terrifying, there is nothing to be afraid of. Furthermore, the solution is as simple as possible. You need to clean several directories and try the installation again to fix exceptions during the Magento 2 installation. That’s it. Use the following code to clear <magento_root>/generated/code and other directories under var and generated:
1 |
rm -rf <magento_root>/generated/code/* <magento_root>/generated/metadata/* <magento_root>/var/cache/* |
Now, try to install Magento 2 once again. This time, no exceptions should occur. For further information, check this material: