MESA-LOADER failed to find dri_gdm.so

I am attempting to add a new package hslinkupper on nixpkgs. My package can be build but cannot run properly:

$ hslinkupper
MESA-LOADER: failed to open dri: /run/opengl-driver/lib/gbm/dri_gbm.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/gbm, suffix _gbm)
Failed to create GBM device for DRM node: /dev/dri/renderD128: No such file or directory
MESA-LOADER: failed to open dri: /run/opengl-driver/lib/gbm/dri_gbm.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/gbm, suffix _gbm)
Failed to create GBM device for DRM node: /dev/dri/renderD128: No such file or directory
Failed to get GBM device

I do have hardware.graphics.enable turned on as instructed by the opengl wiki page and I do not have the file /run/opengl-driver/lib/gbm/dri_gbm.so on my system.

My system information:

$ nix-shell -p nix-info --run "nix-info -m"
-B /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib
/nix/store/sl40191daqb78jf204fgz2lq1xlm8fp5-nix-info
/nix/store/4gk773fqcsv4fh2rfkhs9bgfih86fdq8-gcc-13.3.0-lib
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.72, NixOS, 24.11 (Vicuna), 24.11.713790.2b4230bf03de`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.12`
 - channels(root): `"nixos-24.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Any insights would be greatly appreciated!

So, it seems like you’re using NixOS 24.11 but trying to run a package built with nixos-unstable. These two nixpkgs branches have different mesa versions.

Technically it’s always been unsafe to run applications linked against libgbm from a different version of mesa than the mesa used for your system’s drivers. It often works fine, but there is no guarantee and that can often break the ABI, thanks to libgbm.

But nixos-unstable recently merged what is intended to be the last such breaking change. From now on, any NixOS using mesa 24.3 or newer will work with any application using libgbm from mesa 24.3 or newer. They don’t have to be the same version anymore. But as a consequence of how this change works, it’s a hard breaking change for anything before 24.3. So applications using libgbm < 24.3 won’t work with NixOS using mesa >= 24.3 and vice versa.

(btw, your PR’s package.nix takes pkgs as an argument and uses with pkgs;, which you absolutely should not do. Each input you need can be an extra argument to package.nix. Yes, it’s more verbose having to also specify them as arguments, but with is highly discouraged, and getting the inputs out of pkgs instead of as arguments will break cross compilation for reasons I won’t get into).

2 Likes

Thank you for the detailed explanation! I’ll attempt to switch my system to nixos-unstable and align the mesa versions. I have also done refactoring my package.nix to explicitly list dependencies instead of using with pkgs;

did it work out, i have similar issues

Having a similar issue trying to develop a Dioxus app in a devshell:

     Running `target/debug/reader`
MESA-LOADER: failed to open dri: /run/opengl-driver/lib/gbm/dri_gbm.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/gbm, suffix _gbm)
Failed to create GBM device for DRM node: /dev/dri/renderD128: No such file or directory
MESA-LOADER: failed to open dri: /run/opengl-driver/lib/gbm/dri_gbm.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/gbm, suffix _gbm)
Failed to create GBM device for DRM node: /dev/dri/renderD128: No such file or directory
Failed to get GBM device
Failed to get GBM device
Failed to get GBM device
Failed to get GBM device
...

I believe I’m using both stable for the devshell and my system. It was also suggested that naersk’s use of unstable might trigger something, but I tried:

    naersk = {
      url = "github:nix-community/naersk/master";
      inputs.nixpkgs.follows = "nixpkgs";
    };

And nothing changed. My flake/sample project can be found here.

Thanks for any help.

1 Like

Update: Turns out I was using nixpkgs master, not stable. Also cleaned up the flake a bit. Thanks to everyone on Matrix who helped with this.

I’m probably making this repo private in the next day or so, but here’s my full flake sans lock for future reference. To be clear, this no longer throws any errors for me so I’ll probably use it as a template for Dioxus apps going forward.

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
    utils.url = "github:numtide/flake-utils";
    naersk.url = "github:nix-community/naersk/master";
  };

  outputs =
    {
      self,
      nixpkgs,
      utils,
      naersk,
    }:
    utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { inherit system; };
        naersk-lib = pkgs.callPackage naersk { };
        libs = with pkgs; [ xdotool.out ];
      in
      {
        defaultPackage = naersk-lib.buildPackage ./.;
        devShell =
          with pkgs;
          mkShell {
            nativeBuildInputs = [
              clang
              cargo
              rustc
              rustfmt
              rustPackages.clippy
              cargo-binstall
              mold
              pkg-config
              pre-commit
            ];
            buildInputs = [
              webkitgtk_4_1
              gtk3
              xdotool.out
            ];
            shellHook = ''
              pre-commit install
              export RUSTFLAGS="-C link-arg=-Wl,-rpath,${lib.makeLibraryPath libs}";
            '';
            RUST_SRC_PATH = rustPlatform.rustLibSrc;
          };
      }
    );
}
1 Like