Ubuntu with Nix and home-manager: GTK file/save dialogs make applications crash: GDK_PIXBUF env var faulty?

I’m using Nix (not NixOS) on Ubuntu 21 with home-manager to get some applications/services. I noticed that in all GTK applications (for example, firefox), displaying the Open/Save dialog crashes the whole browser. In other words, I cannot save files anymore. These dialogs work if I don’t use ~/.xsession (managed by home-manager) but a regular Ubuntu GNOME session.

I suspected something in the environment was at fault, so I compared both env outputs. If I unset GDK_PIXBUF_MODULE_FILE, everything works again. The variable gets set to /nix/store/7ids0vgrzwdlgaijg0ai7lqk1nnr5nly-librsvg-2.50.7/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache on my machine.

Anyone have a clue what this error might be caused by? What’s this variable and why is it set?

Hello @pimiddy, have you managed to find a solution to this problem? I’m struggling with the same issue. I intend to check if gtk installed apps like firefox installed via nixpkg instead of ubuntu resolves the issue but it’s less than ideal…

Sorry, I haven’t found a solution yet. I’d also appreciate a solution that doesn’t just wrap firefox or something, and works generally.

Today I’ve found ugly hack that seems to work pretty well in my case.

I’m launching almost all applications via rofi and there’s an option to define custom run command.

So I do this:

  rofiRunCommand = pkgs.writers.writeBashBin "rofi-run-command" ''
    unset GDK_PIXBUF_MODULE_FILE

    exec "$@"
  '';

and then

 config.programs.rofi = {
    enable = true;
    extraConfig = {
      run-command = "${rofiRunCommand}/bin/rofi-run-command {cmd}";
    };
  };

This seems to work pretty well.

I’ve also subscribed to Programs using gdk_pixbuf 2.38 crash with 2.36 loaders from system · Issue #54278 · NixOS/nixpkgs · GitHub which looks related.

1 Like

This problem has, for me, solved itself by upgrading Ubuntu to 21. It might have something to do with Ubuntu now using the Snap version of Firefox.

Thanks @arathunku that worked perfectly! Sadly it’s the kind of bug where I only found this solution once I already knew the problen

To give more details for SEO for other people to find: when launching a Gtk app with dmenu on nix home manager I got an error like

(baobab:289700): Gtk-WARNING **: 13:24:27.298: Failed to load icon /usr/share/icons/breeze/devices/64/drive-harddisk.svg: Unable to load image-loading module: /nix/store/pkzazws2g32fhqdmqw8xvqmp3lz1z28g-librsvg-2.58.3/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.so: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found (required by /nix/store/pkzazws2g32fhqdmqw8xvqmp3lz1z28g-librsvg-2.58.3/lib/librsvg-2.so.2)

For instance, launching baobab this way showed lots of missing icons. If I launched baobab on the terminal like usual, all the icons are there

To find all the env variables which are different, create a custom .desktop application which runs a simple script like this

#!/bin/bash
env >> ~/.local/share/env.txt

and run from dmenu. Compare this with diff to just env and find GDK_PIXBUF_MODULE_FILE is different which implicates the rsvg as seen above

Sadly, unlike other env variables, even if you wrap the outer rofi command to unset GDK_PIXBUF_MODULE_FILE, it will be set before running the command (other env variables are just passed through)