Application complaining about lacking runtime dependencies, although I included the dependencies in the stage-packages

My application utilizes SDL2, SDL2-ttf, and SDL2-image. And it runs perfectly when I’m testing or when I snap it in devmode. But if I snap it using the strict mode, the app runs as if the SDL2 binaries were lacking, it display the error: Video subsystem has not been initialized.

My snapcraft.yaml file:

base: core20 
grade: stable
confinement: strict

apps:
  my-app:
    command: bin/my-app
    environment:
      LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$LD_LIBRARY_PATH"
    plugs:
      - desktop
      - desktop-legacy
      - x11
      - wayland
  
parts:
  binary:
    source: .
    plugin: dump
    organize:
      snap/local/my-app: bin/my-app
     
    stage-packages:
      - libsdl2-dev
      - libsdl2-image-dev
      - libsdl2-ttf-dev
      - libsdl2-2.0-0
      - libsdl2-image-2.0-0
      - libsdl2-ttf-2.0-0
      - g++
      - gcc
      - libpulse0
      - libgl1-mesa-glx


  media:
    source: .
    plugin: dump
    organize:
      snap/local/media/*: media/

As one can see I included the normal and development SDL2 binaries.

I only added the environment part and the other things (gcc, g++, libpulse0) in stage-packages because the application was also complaining about lacking another library, some related to libpulse0, but I think this library is unnecessary or should already come with the others standard things.

Thanks everyone.

sudo snap install snappy-debug

when running your app, open a second terminal before and run snappy-debug in it, and check the output.

You’ll need at least one of the desktop plugs, and most sdl2 apps need the libgl1-mesa-glx package.

snappy-debug
INFO: Following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug
sysctl: permission denied on key 'kernel.printk_ratelimit'
= AppArmor =
Time: Jun 13 16:33:47
Log: apparmor="DENIED" operation="connect" profile="snap.tic-tac-toe-x.tic-tac-toe-x" pid=35087 comm="tic-tac-toe-x" family="unix" sock_type="stream" protocol=0 requested_mask="send receive connect" denied_mask="send connect" addr=none peer_addr="@/tmp/.X11-unix/X1" peer="unconfined"

This is the output, and unfortunately (and obviously) I don’t know what this words mean.
I don’t know if this matter but I ran only snapcraft to snap the package, not sudo snapcraft.

Thanks for your attention.

PS: my application name is tic-tac-toe-x

I tried adding libgl1-mesa-glx to stage-packages but it didn’t fix the problem.
Which is the desktop plug you are talking about?

You need to give your app permissions to run as a desktop app. There’s a section in the tutorial about this. Have a look at one of my snaps at https://raw.githubusercontent.com/mcphail/talesofmajeyal/master/snap/snapcraft.yaml which has the unity7 plug, which is one of those granting desktop access.

Are you sure this is the full output ? normally the very next line has a suggestion … and this particulary error has even an easy one … “add a desktop interface plug or at least the x11 one”

Unfortunately it is the full output: Screenshot%20from%202020-06-13%2020-17-25

I added x11 and some other plugs to my program (see the update in my snapcraft.yaml file) and it keeps not working, but this time I received two error messages more helpful (I think).

When I run my application I receive this error:

MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
X Error:  GLXBadContext
  Request Major code 151 (GLX)
  Request Minor code 6 ()
  Error Serial #107
  Current Serial #106

And in snappy-debug I receive this error:

INFO: Following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug
kernel.printk_ratelimit = 0
= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGL.so.1.7.0" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGL.so.1.7.0 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGL.so.1.7.0" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGL.so.1.7.0 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGLdispatch.so.0.0.0" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGLdispatch.so.0.0.0 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGLdispatch.so.0.0.0" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGLdispatch.so.0.0.0 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGLX.so.0.0.0" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGLX.so.0.0.0 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGLX.so.0.0.0" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGLX.so.0.0.0 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGLX_nvidia.so.440.64" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/x86_64-linux-gnu/libGLX_nvidia.so.440.64 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

= AppArmor =
Time: Jun 15 01:39:56
Log: apparmor="DENIED" operation="open" profile="snap.tic-tac-toe-x.tic-tac-toe-x" name="/var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGLX_nvidia.so.440.64" pid=6470 comm="tic-tac-toe-x" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /var/lib/snapd/hostfs/usr/lib/i386-linux-gnu/libGLX_nvidia.so.440.64 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

PS: I tried the first suggestion and changed all the directories in my code to relative ones (for example: “/…/media/my_font”), but it was worthless. And also, it didn’t seem the root of the problem, since my first version of the application don’t use relative directories and nor $SNAP, but even so works perfectly.

Thanks again for trying to help me :slight_smile: