fix issue with $directory being defined twice

[#63979468]