
Magento 2.0 : Fatal error: Uncaught exception ‘Magento\Framework\Exception\LocalizedException’ with message ‘Can’t create directory
This error message is indicating that Magento is unable to create a directory. This could be due to a number of reasons, such as:
- Permission issues – Magento may not have the necessary permissions to create a directory in the specified location.
- Disk space – The server may be out of disk space, preventing Magento from creating a new directory.
- Incorrect file path – The file path specified in the error message may be incorrect, preventing Magento from finding the correct location to create a new directory.
To troubleshoot this error, you can try the following:
- Check the file permissions of the directory where Magento is trying to create a new directory, and ensure that the user running the Magento process has the necessary permissions.
- Check the disk space on the server, and ensure that there is enough free space for Magento to create a new directory.
- Verify the path in the error message, and ensure that it is the correct path for the location where Magento is trying to create a new directory.
Additionally, you can check the Magento logs for more information on the error, and see the exception trace to locate which method and line is causing the error.
You may encounter the below fatal error While installing Magento 2.0
Fatal error: Uncaught exception ‘Magento\Framework\Exception\LocalizedException’ with message ‘Can’t create directory /home/tahir/www/magento-2.0/var/generation/Magento/Framework/App/ResourceConnection/.’ in /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Generator.php:103 Stack trace: #0 /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass(‘Magento\Framewo…’) #1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load(‘Magento\Framewo…’) #2 [internal function]: spl_autoload_call(‘Magento\Framewo…’) #3 /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct(‘Magento\Framewo…’) #4 /home/tahir/www/magento-2.0/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor(‘Magento\Framewo…’) #5 /home/tahir/www/magento-2.0/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(7 in /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Generator.php on line 103
Solution:
Changing permissions of /var
directory will solve the issue. Run below command from root of your Magento 2.0 directory.
sudo chmod 755 -R var