Error "Failed to initialize Swarm. Check to make sure you have the right version of Swarm installed." when trying to build the lighting of my project

Recently I built the 4.24.3 version of UE from source to work on a project that requires some modifications in the source code. The problem is that every time I try to build the lighting the following error pops up “Failed to initialize Swarm. Check to make sure you have the right version of Swarm installed.” and the lighting doesn’t build. I tried building different versions of the engine from source but the error is still appearing. I’m quite desperate at this point so any help would be really appreciated.

Kind regards!

The problem lies in the function static void MakeEngineDir(FString& OutEngineDir) located in the file Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformMisc.cpp and it exists in all versions currently from 4.27 to 5.1 (and presumably existed back in 4.24).

You want to find the function (different lines for different versions, between 800 and 1100 in the file specified), and then find the lines:


	FString DirToTry = BaseDir / DefaultEngineDir / TEXT("Binaries");
	if (PlatformFile.DirectoryExists(*DirToTry))
	{
		OutEngineDir = MoveTemp(DefaultEngineDir);
		return;
	}

And just delete the / TEXT("Binaries") from the first line there and modify the MoveTemp param to read:


	FString DirToTry = BaseDir / DefaultEngineDir;
	if (PlatformFile.DirectoryExists(*DirToTry))
	{
		OutEngineDir = MoveTemp(DirToTry);
		return;
	}

Every function I can find in the engine relying on EngineDir expects the path to be relative to Engine and not in a sub-dir already, particularly true for shaders and swarm lighting.

I suspect when you have the engine source in the same location with the project you are working on, such as when working on an official plugin or other program within the UE4/UE5 source, then the paths work out as the default branch, but this branch is broken for the case where you have a solution with the engine project and your own project located in different root directories or even different drives. I can’t imagine if it were broken for all cases, the bug would still exist for this long.

If you are a root-level project, your EngineDir is FString DefaultEngineDir = TEXT("../../../Engine/"); which ends in what the calling code expects.

This is the least intrusive fix, so as to remain easy to merge with future commits from unreal; if you want to completely refactor the function in your own build, it is not particularly well written and can be cleaned up quite a bit.