Skip to content

libclang.so.19.1.2 could not be opened: libz.so.1: cannot open shared object file: No such file or directory" #97

Description

@CDaut

When compiling a simple project I get the following error:

  thread 'main' panicked at /home/CDaut/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bindgen-0.71.1/lib.rs:604:27:
  Unable to find libclang: "the `libclang` shared library at /home/CDaut/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-19.1.2_20250225/esp-clang/lib/libclang.so.19.1.2 could not be opened: libz.so.1: cannot open shared object file: No such file or directory"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I am using the esp-dev overlay using the following flake:

{
  description = "A Nix-flake-based Rust ESP IDF development environment";

  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

  outputs = { self, nixpkgs }:
    let
      supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];

      nixpkgs-esp-dev = builtins.fetchGit {
        url = "https://github.com/mirrexagon/nixpkgs-esp-dev.git";

        # Optionally pin to a specific commit of `nixpkgs-esp-dev`.
        rev = "6c34f2436015eb6c107970d9b88f3d5d4600c6fa";
      };
      forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
        pkgs = import nixpkgs { inherit system; overlays = [ (import "${nixpkgs-esp-dev}/overlay.nix") ]; };
      });
    in
    {
      devShells = forEachSupportedSystem
        ({ pkgs }: {
          default = pkgs.mkShell
            {
              packages = with pkgs; [
                esp-idf-full
                espflash
                cargo-espflash
                espup
                libz
              ];
            };
        });
    };
}

espup is installed at version 0.51.1
LIBCLANG_PATH is set to /home/CDaut/.rustup/toolchains/esp/xtensa-esp32-elf-clang/esp-19.1.2_20250225/esp-clang/lib as specified in ~/export-esp.sh

The specified directory contains the file libclang.so.19.1.2 so I really don't see why the file would not be found.

I guess this is related to this dev flake but am unsure. Any help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions