I'm currently running a Magento 2 (2.2.7) site and I've been getting the following error in the CLI when I enter certain commands (usually to do with enabling/disabling modules).

The directory "/var/www/vhosts/websitename.com/httpdocs/generated/code/Magento/Framework" cannot be deleted Warning!rmdir(/var/www/vhosts/websitename.com/httpdocs/generated/code/Magento/Framework): Directory not empty

I've also had some errors relating to Framework when certain modules are enabled.

I wondered what this error was and how to stop if from happening as I'm sure it's having some impact on my site.

1 Answer 1


Are you sure you are running the command with the correct user ?

Have a look at the following page, in which it is stated "Run all Magento CLI commands as the Magento file system owner."


Anyway, the generated folder contains all the files generated at runtime by Magento and should not cause any problem to remove all file that remains after a cache:clean command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.