I can't delete the folder generated/code in Magento 2.2.6

Chen Hanhan picture Chen Hanhan · Oct 4, 2018 · Viewed 9.5k times · Source

I use Docker for my project. After installing the 2.2.6 package with sample data, it gives me problems like the following when I execute php bin/magento cache:clean

The file "/var/www/html/src/generated/code/Magento/Backend/App/Request/PathInfoProcessor/Proxy.php" cannot be deleted Warning!unlink(/var/www/html/src/generated/code/Magento/Backend/App/Request/PathInfoProcessor/Proxy.php): No such file or directory

The generated/code folder can not be deleted and I have to restart my computer then it does let me delete the folder

I use php 7.1.22 , percona 5.6.39 and docker Version 18.06.1-ce-win73 (19507)

Answer

Andrew Smith picture Andrew Smith · Oct 5, 2018

This happens due to insufficient permissions on the project folder and files.Also www-data must be owner of the project if using Apache as web-server. Please execute commands given below:--

  • sudo chown -R www-data:www-data [path to magento directory]
  • navigate to root of your magento project
  • find . -type f -exec chmod 644 {} ;
  • find . -type d -exec chmod 755 {} ;
  • find ./var -type d -exec chmod 777 {} ;
  • find ./pub/media -type d -exec chmod 777 {} ;
  • find ./pub/static -type d -exec chmod 777 {} ;
  • chmod 777 ./app/etc
  • chmod 644 ./app/etc/*.xml
  • chmod u+x bin/magento