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/, for GNU/Linux 3.2.0, BuildID[sha1]=79f70d4f011b115ccfad3ca4e68445acf0f953af, stripped

# ldd clangd (0x00007ffe59bf0000) => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/ (0x00007f92f0a29000) => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/ (0x00007f92f0a1e000) => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/ (0x00007f92f0a19000) => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/ (0x00007f92f08d6000) => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib/ (0x00007f92f0715000)
/lib64/ => /nix/store/jsp3h3wpzc842j0rz61m5ly71ak6qgdn-glibc-2.32-54/lib64/ (0x00007f92f0a4c000)

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



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/ 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

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