nix-community / nix-ld

Run unpatched dynamic binaries on NixOS [maintainer=@Mic92]
MIT License
942 stars 14 forks source link

Failing on xournalpp? #95

Open tobiasBora opened 6 days ago

tobiasBora commented 6 days ago

Thanks for this great tool. But I'm a bit confused: I'd expect nix-ld to work also for appimages that I downloaded in https://github.com/xournalpp/xournalpp/releases, but it fails:

$ ./xournalpp-1.2.4+dev-nightly.20241107-x86_64.AppImage
Gtk-Message: 16:17:14.178: Failed to load module "colorreload-gtk-module"
Gtk-Message: 16:17:14.179: Failed to load module "window-decorations-gtk-module"
ALSA lib pcm.c:2793:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2793:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2793:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:878:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:878:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:878:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:878:(find_matching_chmap) Found no matching channel map
xopp-Message: 16:17:14.384: Plugin "MigrateFontSizes" UI initialized

(com.github.xournalpp.xournalpp:742328): Gtk-WARNING **: 16:17:14.392: Could not load image 'pixmaps/com.github.xournalpp.xournalpp.svg': Unable to load image-loading module: libpixbufloader-svg.so: libpixbufloader-svg.so: cannot open shared object file: No such file or directory

(com.github.xournalpp.xournalpp:742328): Gtk-WARNING **: 16:17:14.680: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.

(com.github.xournalpp.xournalpp:742328): Gtk-WARNING **: 16:17:14.703: im-ibus.so: cannot open shared object file: No such file or directory

(com.github.xournalpp.xournalpp:742328): Gtk-WARNING **: 16:17:14.703: Loading IM context type 'ibus' failed

(com.github.xournalpp.xournalpp:742328): Gtk-WARNING **: 16:17:14.703: cache version is different 1 != 2

(com.github.xournalpp.xournalpp:742328): Gtk-WARNING **: 16:17:14.813: im-ibus.so: cannot open shared object file: No such file or directory

(com.github.xournalpp.xournalpp:742328): Gtk-WARNING **: 16:17:14.813: Loading IM context type 'ibus' failed
**
Gtk:ERROR:../gtk/gtkiconhelper.c:495:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /nix/store/9dlny4xviyp4sjlq93s7k99374xpf6qg-breeze-icons-6.7.0/share/icons/breeze-dark/status/24/image-missing.svg: Impossible de charger le module de chargement d’images : libpixbufloader-svg.so : libpixbufloader-svg.so: cannot open shared object file: No such file or directory (gdk-pixbuf-error-quark, 5)
Bail out! Gtk:ERROR:../gtk/gtkiconhelper.c:495:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /nix/store/9dlny4xviyp4sjlq93s7k99374xpf6qg-breeze-icons-6.7.0/share/icons/breeze-dark/status/24/image-missing.svg: Impossible de charger le module de chargement d’images : libpixbufloader-svg.so : libpixbufloader-svg.so: cannot open shared object file: No such file or directory (gdk-pixbuf-error-quark, 5)

(com.github.xournalpp.xournalpp:742328): xopp-WARNING **: 16:17:15.029: [Crash Handler] Crashed with signal 6

(com.github.xournalpp.xournalpp:742328): xopp-WARNING **: 16:17:15.029: [Crash Handler] Wrote crash log to: /home/leo/.cache/xournalpp/errorlogs/errorlog.20241108-161715.log

(com.github.xournalpp.xournalpp:742328): xopp-WARNING **: 16:17:15.273: Essai d'un enregistrement d'urgence du document ouvert...

(com.github.xournalpp.xournalpp:742328): xopp-WARNING **: 16:17:15.273: Document enregistré avec succès dans "/home/leo/.config/xournalpp/emergencysave.xopp "

I do see errors related to ibus.so and libpixbufloader-svg.so, but I have them enabled already:

  # Automatically creates a loader in /lib/* to avoid patching stuff
  # To disable it temporarily use
  # unset NIX_LD
  programs.nix-ld = {
    enable = true;
    libraries = with pkgs; [
      # List by default
      zlib
      zstd
      stdenv.cc.cc
      curl
      openssl
      attr
      libssh
      bzip2
      libxml2
      acl
      libsodium
      util-linux
      xz
      systemd

      # My own additions
        xorg.libXcomposite
      xorg.libXtst
      xorg.libXrandr
      xorg.libXext
      xorg.libX11
      xorg.libXfixes
      libGL
      libva
      pipewire
      xorg.libxcb
      xorg.libXdamage
      xorg.libxshmfence
      xorg.libXxf86vm
      libelf

      # Required
      glib
      gtk2

      # Without these it silently fails
      xorg.libXinerama
      xorg.libXcursor
      xorg.libXrender
      xorg.libXScrnSaver
      xorg.libXi
      xorg.libSM
      xorg.libICE
      gnome2.GConf
      nspr
      nss
      cups
      libcap
      SDL2
      libusb1
      dbus-glib
      ffmpeg
      # Only libraries are needed from those two
      libudev0-shim

      # needed to run unity
      gtk3
      icu
      libnotify
      gsettings-desktop-schemas
      # https://github.com/NixOS/nixpkgs/issues/72282
      # https://github.com/NixOS/nixpkgs/blob/2e87260fafdd3d18aa1719246fd704b35e55b0f2/pkgs/applications/misc/joplin-desktop/default.nix#L16
      # log in /home/leo/.config/unity3d/Editor.log
      # it will segfault when opening files if you don’t do:
      # export XDG_DATA_DIRS=/nix/store/0nfsywbk0qml4faa7sk3sdfmbd85b7ra-gsettings-desktop-schemas-43.0/share/gsettings-schemas/gsettings-desktop-schemas-43.0:/nix/store/rkscn1raa3x850zq7jp9q3j5ghcf6zi2-gtk+3-3.24.35/share/gsettings-schemas/gtk+3-3.24.35/:$XDG_DATA_DIRS
      # other issue: (Unity:377230): GLib-GIO-CRITICAL **: 21:09:04.706: g_dbus_proxy_call_sync_internal: assertion 'G_IS_DBUS_PROXY (proxy)' failed

      # Verified games requirements
      xorg.libXt
      xorg.libXmu
      libogg
      libvorbis
      SDL
      SDL2_image
      glew110
      libidn
      tbb

      # Other things from runtime
      flac
      freeglut
      libjpeg
      libpng
      libpng12
      libsamplerate
      libmikmod
      libtheora
      libtiff
      pixman
      speex
      SDL_image
      SDL_ttf
      SDL_mixer
      SDL2_ttf
      SDL2_mixer
      libappindicator-gtk2
      libdbusmenu-gtk2
      libindicator-gtk2
      libcaca
      libcanberra
      libgcrypt
      libvpx
      librsvg
      xorg.libXft
      libvdpau
      # ...
      # Some more libraries that I needed to run programs
      gnome2.pango
      cairo
      atk
      gdk-pixbuf
      fontconfig
      freetype
      dbus
      alsaLib
      expat
      # Needed for electron
      libdrm
      mesa
      libxkbcommon
      # Needed to run, via virtualenv + pip, matplotlib & tikzplotlib
      stdenv.cc.cc.lib # to provide libstdc++.so.6
      pkgs.gcc-unwrapped.lib # maybe only the first one needed

      # needed to run appimages
      fuse # needed for musescore 4.2.1 appimage
      e2fsprogs # needed for musescore 4.2.1 appimage
      fribidi # needed for xournalpp (nightly 08/11/2024)
      librsvg # needed for xournalpp (nightly)
      ibus # needed for xournalpp (nightly)
    ];
  };  

On the other hand, appimage-run works better (at least I can start the program).

I can't really explain this bug, so sorry if this is unrelated, but since appimage-run kinds of work, I thought it would be a nix-ld related bug. Tested on kde plasma 6, wayland, recent nixos unstable.

Mic92 commented 6 days ago

You can restart xournalpp with LD_DEBUG=libs set as environment variables. Than glibc will tell you exactly in which directories it has been trying to lookup your library. Hopefully this will make it obvious why it can't load from /run/current-system/sw/share/nix-ld/lib/. Also make sure you are testing with nix-ld > v2.0.0 as it has changed significantly it's implementation.