SetVar Include - Environment variable name or value is too long

I having a problem updating a project from 5.7 to 5.8. I did an update as a copy and that worked fine. Then, I updated in-place and it gave the SetEnv" task failed unexpectedly. - Environment variable name or value is too long.

I rolled back and got the same error.

I then tried cloning from my repo from 5.7, right clicked on project and converted to 5.8. I updated my plugin source to the 5.8 versions. I generated the solution. Opened VS. Waited for NuGet Packages. Went to build and got the same error again.

Any ideas?

@Junkmuppet That error usually isn’t the project conversion itself, it’s a build environment issue.A few things I’d try:
Move the project somewhere with a short path (e.g. C:\UE58\Project).
Delete Binaries, Intermediate, and .vs, then regenerate project files.
Temporarily disable any third-party plugins and see if it builds. Check your Windows PATH variable hasn’t become ridiculously long.

Since you’re getting the same error from a fresh clone, my first suspicion would be a plugin or build path issue rather than the project itself. Also, can you post the lines just above the SetEnv task failed unexpectedly error? That’s usually where the real problem shows up.

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.