I get "The requested class did not generate properly, because the 'generated' directory permission is read-only" during setup:di:compile even though the folder has 777 permission.
I even tried with sudo, but I get the same error.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityTry this command from CLI.
sudo chmod -R 777 var/ generated/
Try below setps and check.
rm -rf pub/static/frontend/ pub/static/adminhtml/ var/{cache,composer_home,page_cache,view_preprocesseds,di} generated/*
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo chmod -R 777 var/ generated/ pub/
Let me know if any query.
THANKS.
Remove generated directory with the root user.
sudo rm -rf generated
Then switch to the Web server user (typically, it is www-data)
Finally, compile code:
bin/magento setup:di:compile