Freedesktop icons missing

Hello my app crashes in the runtime (fails to load) due to the lack of some icons. Here’s my snapcraft.yaml:

name: nixwriter
base: core20
version: "2.0.0"
summary: Bootable Linux image writer
description: |
  Create bootable Linux images into flash drives from a simple user interface.

grade: devel 
confinement: devmode 

parts:
  nixwriter:
    source: "."
    plugin: rust
    build-packages:
      - libgtk-3-dev
    stage-packages:
      - libgtk-3-0
      - adwaita-icon-theme-full
      - gnome-icon-theme
      - hicolor-icon-theme
  
apps:
  nixwriter:
    command: bin/nixwriter
    plugs:
      - desktop
      - desktop-legacy
      - x11
      - wayland
      - udisks2
      - removable-media

The error I get is:

(nixwriter:20173): Gtk-WARNING **: 18:16:56.679: Could not find the icon ‘user-home-symbolic-ltr’. The ‘hicolor’ theme
was not found either, perhaps you need to install it.
You can get a copy from:
http://icon-theme.freedesktop.org/releases

(nixwriter:20173): Gtk-WARNING **: 18:16:56.679: 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)
Bail out! 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)
zsh: abort (core dumped) nixwriter

I tried to use the gnome-3-24 extension but that would not work under core20. And the project fails to build under core18 due to some C missing library features and fails to compile.

How can I give the snap access to the freedesktop icons?

by using a desktop launcher … (or by setting all the required environment variables manually)

I want to add that the desktop extensions are now the recommended way to create a snap for desktop applications. The snapcraft-desktop-helpers project should only be used for a few very specific situations such as 32-bit applications and legacy GTK+ 2 applications.

@adnan338 for your application I would recommend the gnome-3-28 extension. This one is specifically built for GTK 3 applications. It automatically adds the desktop launcher to your snap and includes an number of improvements to make your snap smaller, start quicker, and make it use the system themes.

See GTK 3 applications for a complete tutorial on how to create a snap for a GTK 3 application.

Edit: I didn’t see that you require core20. A gnome extensions for core20 is in the works, but not released yet.

well, it really depends on your project … for snaps that i design specifically for desktop-only use i definitely use the extensions … but i have enough snaps in the store that i want to be used in other contexts (i.e. kiosk setups on core) where i don’t really want to have an additional snap of ~300MB downloaded alongside …

Ok, I agree the desktop helpers can still be useful for kiosks.

Your comment made me curious what the space savings were on the desktop.

  • gnome-3-28-1804 is 169MB.
  • gtk-common-themes is 65MB.
  • When I switched one of my snaps to the extension, its size fell by 92MB.

So you’d need about three snaps before gnome-3-28 saves you space. I’m guessing this will be difficult on a kiosk. On my desktop, I have 12 snaps using gnome-3-28, so it makes sense there.

This doesn’t seem to be the case for gnome-3-34, however. Only 2 snaps use it and its size is 267MB.