command line user does not have read and write permissions on generated directory. Please address this issue before using Magento command line

When I was trying to run php bin/magento indexer:reindex.

And I found I get the exactly same error when I tried to run the php bin/magento lines, I checked the post Error after magento upgrade, and have already changed the permission of generated folder, and then give bin/magento file to 744 (executable), and I used ls -l, the ownership of the folder is below to my account. I am using Magento 2.2, So there is no di folder under var folder. So why does this error happen ?

Thanks for any advises.

enter image description here

enter image description here


1 Answer 1


More likely than an issue with bin/magento (even though actually there is no executable bit on any level of access) there is an issue with a generated folder. As you can read in documentation for v2.2 compiled files changed their paths to /generated/*

I assume that you have properly set privileges bits for the previous version but maybe you missed setgid/uid bits and therefore user executing PHP script does not have access to this file (all is a file in Unix, also dirs).

  • Try to run bin/magento with root user. With root user if you didn't get problem then you need to check your normal permission with server support.
    – Mahesh V
    Jul 11, 2020 at 9:48

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.