Binary file does not find libraries in subdir if run as snap package


I’m quite new to creating snap packages, and this is one of my first attempts. I would like to pack an old program (sancho, a front-end for p2p software), that basically is just a binary file (the executable) and a subfolder (‘lib’) with some library dependencies.

I am able to create the snap package (sancho-snap) and install it. However, when I run it (sancho-snap). It can’t find those libraries. But if I run the same file directly, it runs without an issue.

It’s as if, once the program is in the form of a snap package, it can’t “see” the subdirectories in their relative path.

This is the folder structure:

$ ls -R
distrib  lib  sancho

AUTHORS      sancho-48.xpm          sancho.reg
ChangeLog    README          sancho-64.png  
CPL.txt      sancho-128.png
LGPL.txt     sancho-16.xpm  sancho.icns              sancho_pl_PL.properties_ascii  sendalltorrents
LICENSE.txt  sancho-256.png  sancho.ico     
preview.bat  sancho-32.xpm


So basically, when I run the program inside the snap package:

user@host:/$ snap run --shell sancho-snap
user@host:/$ cd /snap/sancho-snap/current/
user@host:/snap/sancho-snap/current$ ./sancho 
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3509 or swt-pi-gtk in swt.library.path, java.library.path or the jar file
        at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
        at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
        at org.eclipse.swt.internal.gtk.OS.<clinit>(Unknown Source)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Unknown Source)
        at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
        at sancho.core.Sancho.main(

But if I just go to /snap/sancho-snap/current and I run the program, works just fine:

user@host:/snap/sancho-snap$ cd /snap/sancho-snap/current/
user@host:/snap/sancho-snap/current$ ./sancho 
[program starts normally]

Any ideas what could be the issue? I’ve spent hours trying already.

how does the apps block in your snapcraft.yaml look like ? do you hand the correct options to the java interpreter to use the correct search paths (or set the right env variables alternatively) ?