jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.83k stars 187 forks source link

Unable to find libclang #2089

Open emlautarom1 opened 1 month ago

emlautarom1 commented 1 month ago

What happened?

Currently I'm working on a Rust project that uses librocksdb-sys as a dependency and I'm unable to build the package when working inside a devbox shell though I can build it outside.

Steps to reproduce

  1. Get a Rust project with librocksdb-sys as a dependency
  2. Add rustup@1.26.0 and libllvm@17.0.6 to your devbox.json file
  3. Try to build the project using cargo build

Command

No response

devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.10.6/.schema/devbox.schema.json",
  "packages": [
    "nodejs@21.7.3",
    "go@1.21.0",
    "gopls@0.15.3",
    "delve@1.21.0",
    "rabbitmq-server@3.12.13",
    "docker@24.0.5",
    "rustup@1.26.0",
    "libllvm@17.0.6",
  ],
  "env": {
    "NIX_HARDENING_ENABLE": ""
  },
  "include": [
    "github:jetify-com/devbox-plugins?dir=rabbitmq"
  ],
  "shell": {
    "init_hook": [
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

Devbox version

0.10.7

Nix version

nix (Nix) 2.18.1

What system does this bug occur on?

Linux (x86-64)

Debug logs

Relevant parts only:

  thread 'main' panicked at /home/emlautarom1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.65.1/lib.rs:603:31:
  Unable to find libclang: "the `libclang` shared library at /usr/lib64/libclang.so.17.0.6 could not be opened: libLLVM-17.so: cannot open shared object file: No such file or directory"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
emlautarom1 commented 1 month ago

Note that /usr/lib64/libclang.so.17.0.6 exists and it's a proper shared object. The issue seems to be when trying to use it from the devbox shell. What I don't understand is why is it picking up the native one instead of the one stored in the Nix store.

croots commented 1 week ago

Also having this issue.

Apparently there's a nix hook rustPlatform.bindgenHook but its not clear how to instruct devbox to use hooks.

Worse than that, now my environment outside of devbox also fails until I restart my shell