Cannot generate compile_commands.json with the build tool in Linux

I’ve installed Unreal Engine 4.25 in Ubuntu, now I’m trying to get autocompletion to work in my preferred editor. For that I need the compile_commands.json. Apparently I need to generate this with the build tool, but when I try to:

 ./Build.sh -project=/home/user/Documents/Unreal/MyProject/MyProject.uproject -mode=GenerateClangDatabase UE4Game Linux Development

I get the following error:

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

Clang is never the less installed, which I did via this command:

sudo apt-get install clang

And seems to be successfully installed:

clang --version

clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Any ideas what could be wrong or how to fix the issue? Is there a better way to generate the compile_commands.json?

I have the same problem on 4.26 on Manjaro.

Any solutions?

This might be old but in case someone is looking for it:

You’re not supposed to use your own clang. Engine source comes with it’s own clang-based toolchain, you gotta download it with ./Setup.sh and then it will be located somewhere under:

UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v22_clang-16.0.6-centos7/x86_64-unknown-linux-gnu/bin

If you’re using binary distribution of the Engine (e.g. from Epic Games Launcher, or from https://www.unrealengine.com/en-US/linux ) then you won’t be able to do this. Binary distributions are only for working in the Editor itself.

I suspect this wasn’t the initial problem that OP encountered, since back in 2020 there were no binary distributions on Linux (unless there was an Ubuntu repository for apt/snap).