Question: 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.

Answer: 
I know its too late to answer, but adding my finding to help others. I have tested this in Magento 2.4.x and below solution is working fine.

1. Create your custom theme.
2. Under Magento\_Theme/layout folder create default\_head\_blocks.xml file.
3. Add you font by using below code:

> 
> <font src="fonts/fontawesome-webfont.woff2"/>
> 
> 
> 

4. Flush the cache & do static-content deploy.

Above code will automatically add in the font. For reference you can check the Luma theme default\_head\_blocks.xml file.

**Note**: For example, if you want to add fontawesome-webfont.woff2?v=4.5.0 then it will not work. It will only work with the exact filename as I mentioned above.
[![enter image description here](https://i.stack.imgur.com/DYbnB.png)](https://i.stack.imgur.com/DYbnB.png)
Hei!

Have a look on this. I guess you can add that on the HTML head.

<https://docs.magento.com/user-guide/design/html-head.html>