Magento – Command line user does not have read and write permissions on generated directory

magento2magento2.2

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

Best Answer

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).

Related Topic