Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdk-pixbuf depends on shared-mime-info #39493

Open
jtojnar opened this issue Apr 25, 2018 · 9 comments
Open

gdk-pixbuf depends on shared-mime-info #39493

jtojnar opened this issue Apr 25, 2018 · 9 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects

Comments

@jtojnar
Copy link
Contributor

jtojnar commented Apr 25, 2018

gdk-pixbuf needs data from shared-mime-info to be available in XDG_DATA_DIRS to work correctly. At the moment, we are patching it to use the inaccurate guessing it resorts to on non-Linux platforms, but it is, well, inaccurate. It is probably also the reason why some installed tests fail with “Unrecognized image file format”.

  • We could wrapProgram every executable that uses gdk-pixbuf (transitively). Even things like emacs, very tiresome.
  • We could patch gdk-pixbuf to modify the XDG_DATA_DIRs environment. A terrible idea, since g_setenv it is not thread-safe.
  • We could hard-code the shared-mime-info path to glib. If gdk-pixbuf is built with mime-sniffing (build system will set GDK_PIXBUF_USE_GIO_MIME), a module loader internal function will call g_content_type_guess, which calls xdgmime functions, which during initialization traverse data dirs; the lattermost file is probably the right place.
A testcase that will fail if we build gdk-pixbuf with MIME sniffing
with import <nixpkgs> { };
with pkgs;

let
  testSrc = writeText "test.c" ''
    #include <gdk-pixbuf/gdk-pixbuf.h>
    #include <glib.h>

    int main(int argc, char const *argv[]) {
        GError* err = NULL;
        if (gdk_pixbuf_new_from_file("${nixos-artwork.wallpapers.gnome-dark}/share/artwork/gnome/Gnome_Dark.png", &err) == NULL) {
            g_error("%s", err->message);
            return 1;
        }

        return 0;
    }
  '';
in runCommand "gdk-pixbuf-loading-test" {
    buildInputs = [ gdk_pixbuf pkgconfig gcc ];
  } ''
    cc \
      $(pkg-config --cflags gdk-pixbuf-2.0) \
      $(pkg-config --libs gdk-pixbuf-2.0) \
      ${testSrc} -o test

    mkdir -p $out
    mv test $out/test

    $out/test
  ''

cc @peti @vcunat

@vcunat
Copy link
Member

vcunat commented May 1, 2018

I agree with hardcoding. Semantically I'd imagine this to be as if appended to the XDG_DATA_DIR search list, in ideal case, so it's still overridable in the usual ways.

There is a small downside for closure sizes: shared-mime-info ATM depends (also) on libxml2.out (which isn't in gdk_pixbuf.out closure ATM). We probably could just split the utility (and locale) away from the data (share/mime). Still, we can defer that to later, as I expect libxml2.out will be present in most larger closures anyway.

@infinisil

This comment has been minimized.

@jtojnar
Copy link
Contributor Author

jtojnar commented Mar 9, 2019

The issue with the third point is a circular dependency. glib would depend on s-m-i, which already depends on glib. Why cannot upstreams be less lazy and split data from utilities like, for example, osinfo did in 1.0. Or build systems could allow to install project components to different prefixes (I guess this did not make sense with FHS).

@stale
Copy link

stale bot commented Jun 3, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2020
@colonelpanic8
Copy link
Contributor

This is still an issue for me.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 30, 2020
@freckletonj
Copy link

Confirming this is still an issue. Emacs frequently crashes, eg when hovering a link in markdown, with the stderr:

(emacs:16021): GLib-GIO-CRITICAL **: 10:18:40.025: g_settings_schema_source_lookup: assertion 'source != NULL' failed

(emacs:16021): Gtk-WARNING **: 10:18:51.057: Could not load a pixbuf from /org/gtk/libgtk/icons/16x16/status/image-missing.png.
This may indicate that pixbuf loaders or the mime database could not be found.
**
Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /org/gtk/libgtk/icons/16x16/status/image-missing.png: Unrecognized image file format (gdk-pixbuf-error-quark, 3)
Fatal error 6: Aborted

and a line in ~/.xsession-errors of user error (Error in function getWindowAttributes).

@freckletonj
Copy link

Hey I'm back again!

I eventually installed emacs via Nix, that seems to have solved this.

I'm back again because nixpkgs was breaking some things (unrelated issues), and I decided to build emacs manually. Now, I've found if I unset XDG_DATA_DIRS, this error goes away. How do I solve this though? I've built emacs 27.2, and it works just fine outside of a nix-shell. I'm on Debian Buster.

@freckletonj
Copy link

freckletonj commented Jul 9, 2021

For deeper context, here's a ticket I haven't seen mentioned elsewhere yet, same issue: direnv/direnv#785
and a blog post

I'm currently solving this with:

# in my .bashrc
export XDG_DATA_DIRS=/usr/share/

@stale
Copy link

stale bot commented Jan 9, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 9, 2022
@jtojnar jtojnar removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 30, 2022
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
GNOME
  
To Do
Development

No branches or pull requests

5 participants