[BUG] Clangd is missing libz.so.1 in lsp
| Field | Description |
|---|---|
| Plugin | lsp |
| Nixpkgs | nixos-unstable |
| Home Manager | 24.11-pre |
- [x] I have read the FAQ and my bug is not listed there.
Description
I'm having trouble running clangd with nixvim. Whenever I run it in my configuration, I see an error of this form:
[ERROR][2025-03-18 15:28:34] .../vim/lsp/rpc.lua:770 "rpc" "/nix/store/zqdqx2z1sng4yqqbwz8cga0dgwv3r37p-clang-tools-18.1.8/bin/clangd" "stderr" "/nix/store/zqdqx2z1sng4yqqbwz8cga0dgwv3r37p-clang-tools-18.1.8/bin/clangd: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory\n"
Minimal, Reproducible Example (MRE)
The setup looks something like this (apologies if this is not the most minimal example, but I'm not 100% sure in which part the error happens...)
#flake.nix
nvim = nixvim'.makeNixvimWithModule {
inherit pkgs;
module = ./config;
};
#config/default.nix
{}:
{
imports = [
lsp.nix
];
}
#lsp.nix
{ pkgs
, ...
}: {
plugins = {
lsp-format = {
enable = true;
};
lsp = {
enable = true;
servers = {
clangd = {
enable = true;
package = pkgs.llvmPackages_18.clang-tools;
cmd = [
"clangd"
"--offset-encoding=utf-16"
"--background-index"
"-j"
"20"
"--clang-tidy"
];
};
};
};
};
}
Which is the used like this in a configuration:
#flake.nix
{
inputs = {
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixvim = {
url = "github:i-ilak/nixvim-config";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
}
outputs = {
...
} @ inputs
: {
homeConfigurations = {
# some deeper nesting, but in the end
home.packages = [
inputs.nixvim.packages.${pkgs.system}.default
];
};
};
}
Any idea why this shared object ins not in the LD_LIBRARY_PATH, or symlinked to the default locations Linux expects?
This is weird indeed. But I feel like this is an issue with how clangd is packaged in nixpkgs whether than a Nixvim issue...
Thought so, will see if I can find anything on nixpkgs and otherwise create new issue there...