How to fix the «Can't create directory 'generated/code' in Magento/Framework/Code/Generator.php» Magento 2.2 issue?

code-generation
compilation
bug
filesystem
filesystem-permissions
magento22

(Dmitry Fedyuk) #1

exception ‘RuntimeException’ with message ‘Can’t create directory generated/code/Magento/Framework/App/ResourceConnection/.’ in lib\internal\Magento\Framework\Code\Generator.php:115

1

2

3


4

5

So the issue is caused by insufficient filesystem permissions.


Since 2016-12-28, the «var/generation» folder has been renamed to «generated/code» in Magento 2.2
How to fix the «Can't create directory var/generation» issue?
How to fix the «cache_dir "var/cache" is not writable» issue?
(Dmitry Fedyuk) #2

How to fix

Grant the PHP interpreter the writable permissions to the generated folder:

chmod -R -v 777 generated

(Dmitry Fedyuk) #3

See also:


(Alex Hlynskyy) #4

isn’t it dangerous to give 777 to generated ?


(Dmitry Fedyuk) #5

Why should it be dangerous?