I have this issue that is driving me crazy and has me going around in circles. I am unable to find anything relating to a solution online so hoping someone here will be able to answer this.
We have a 2.3.5p1 store that we put in production mode to test and then back into developer mode.
Since then, I am trying to disable a module but I get:
"The directory "/home/redacted/public_html/generated/code/Magento" cannot be deleted Warning!rmdir(/home/redacted/public_html/generated/code/Magento): Directory not empty"
So I ran rm -rf generated/metadata/* generated/code/* and this clears almost all of the generated/code contents except /generated/code/Magento/Framework because "Directory not empty".
A philosopher would argue as to the need to delete a directory that was already empty, but hey...
Anyway, I can see all other folders are gone but as I refresh my view they all start popping up again until the full folder and file structure is back to how it was. Nobody is visiting the front end of the site in order to create generated code on the fly and the site is definitely in developer mode (as deploy:mode:show tells me and also as I see inside env.php).
So I am stuck needing to empty the generated directory in order to disable the extension and not being able to empty it because "it's not empty".
Grateful for your feedback.