{{ directory }} not available in parts of menu--main.html.twig
The second occurrence of {{ directory }} is within a Twig macro. As the Twig documentation mentions, you cannot access the outer variables in a macro:


  But as with PHP functions, macros don't have access to the current template variables.


You can however pass _context through a macro parameter and access directory that way, or pass it explicitly.