ERROR: Clang must be installed in order to build this target

I’ve been trying to generate a clang database to use with my editor on linux for what amounts to 3 days now and UBT doesn’t seem to want to do that. I’ve tried tweaking the ClangPath at Engine/Source/Programs/UnrealBuildTool/Platform/Linux/LinuxToolchain.cs, tried setting environment variables, tried tweaking the Engine/Build/BatchFiles/Linux/ script but it seems UBT don’t want to work on this mode. And yes, I have both the engine clang toolchain and the compiler installed locally

HI! I just have the same problem and it seems that UBT actually checks for clang.exe path to be present. I tried to generalize it in this PR to work for Mac and Linux.
I tested in Linux and it generated the database.

I have encountered with the same problems. I check the source code that I found out the exception was thrown out from c# file VCEnvironment.cs where you should ensure the variable ToolChain to be your own Visual Studio version. In my occasion, problems solved. Hope this may be helpful.

			if(Compiler == WindowsCompiler.Clang || Compiler == WindowsCompiler.Intel)
				ToolChain = WindowsCompiler.VisualStudio2019;
				if(!WindowsPlatform.TryGetToolChainDir(ToolChain, null, out SelectedToolChainVersion, out SelectedToolChainDir))
					throw new BuildException("{0}{1} must be installed in order to build this target.", WindowsPlatform.GetCompilerName(Compiler), String.IsNullOrEmpty(CompilerVersion)? "" : String.Format(" ({0})", CompilerVersion));

In case anyone stumbles upon this thread, I’ve just fixed this error error on Windows by setting LLVM_PATH environment variable to a directory where LLVM was installed. See FindToolChainInstallations method in UEBuildWindows.cs for details.