I tried making a short path to the project and even tried using mklink /J “D:\UE5.8” “D:\Program Files\Epic Games\UE_5.8\Engine” to have it short.
ended up finding the solution in another post Enviroment variable too long - Development / Programming & Scripting - Epic Developer Community Forums
I deleted BuildConfiguration.xml in C:\Users\{YOURUSERNAME}\AppData\Roaming\Unreal Engine\UnrealBuildTool. Then, cleared folders, rebuild solution, and it worked.