Prebuild binary does not exist or could not be executed

I failed to run prebuild clangd on nixos with output

Failed to execute process './clangd'. Reason:
The file './clangd' does not exist or could not be executed.

I have googled it, most cases are missing share lib, but clangd has all the needed provided

# file clangd
clangd: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=79f70d4f011b115ccfad3ca4e68445acf0f953af, stripped

# ldd clangd
linux-vdso.so.1 (0x00007ffe59bf0000)
libpthread.so.0 => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/libpthread.so.0 (0x00007f92f0a29000)
librt.so.1 => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/librt.so.1 (0x00007f92f0a1e000)
libdl.so.2 => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/libdl.so.2 (0x00007f92f0a19000)
libm.so.6 => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/libm.so.6 (0x00007f92f08d6000)
libc.so.6 => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/libc.so.6 (0x00007f92f0715000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib64/ld-linux-x86-64.so.2 (0x00007f92f0a4c000)

so what’s the real reason for it failed to excute?

Thanks.

====================

my system is

Linux 5.10.71 #1-NixOS SMP Wed Oct 6 13:56:04 UTC 2021 x86_64 GNU/Linux

Seems you obtained a clangd from a source different than nixpkgs.
What you’re experiencing is the lack of linker located at /lib64/ld-linux-x86-64.so.2 on NixOS with the somewhat misleading error message talking about the wrong file.

There’s a couple of options:

Also: I wouldn’t trust output of ldd, which claims that clangd would be able to find glibc and such.

I think this is because the ldd executable incorrectly suggests its own glibc.

You can use readelf -d instead, which will report you the interpreter and runpath stored in the binary.

1 Like

There’s also more to learn in the wiki: Packaging/Binaries - NixOS Wiki

Thanks.
My purpose is to build a docker image with my favor tools, like tmux, neovim, lsp plugin, so I hope this image could be as small as possible.

  • I did try nixpkgs.clang-tools, but it is a soft link to a whole llvm-clang tool set, which is too big, around 1GB size with it’s dependencies.
  • the reason I tried prebuilt clangd is for it’s 40MB size after stripped
  • I also tried building clangd from souce code by nix, but it costs too much time on my laptop, and I still not succeed to build it for the failure at install phase

I will try patchelf later