Skip to content

clangd: Missing libz.so.1 when running clangd #391356

Open
@i-ilak

Description

@i-ilak

Nixpkgs version

  • Unstable (25.05)

Describe the bug

This issue came up when configuring nixvim. The same configuration was working until ~3 weeks.

Field Description
Plugin lsp
Nixpkgs nixos-unstable
Home Manager 24.11-pre

Description

Whenever I run nixvim with my configuration on a C++ codebase, that starts lsp, 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"

Any idea why this shared object ins not in the LD_LIBRARY_PATH, or symlinked to the default locations Linux expects?

Steps to reproduce

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
        ];
      };
    };
}

Regardless of pkgs.clang-tools, or pkgs.llvmPackages_18.clang-tools, the issue persists.

Expected behaviour

For clangd to start normally and work.

Screenshots

No response

Relevant log output

Additional context

Double checking with nixvim maintainer here, indicate that this is a clangd issue.

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.8.0-51-generic, Ubuntu, 24.04.1 LTS (Noble Numbat), nobuild
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.25.3
  • nixpkgs: /nix/store/shh5sdqk4h0s482fxyyw6v5hhljapby9-source

Notify maintainers

@Patryk27


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions