My snap does not find its libraries, still they are included in the package

Hello everybody,

The strange behavior of the snap that I have just compiled :

I have 2 systems installed on my machine : first system :“Linux Mint 19” which is based on “Ubuntu 18.04 bionic” second system : “Ubuntu 20.04” I have developed on my first system an open source application "furch-diaoulek"to help in the learning of languages. This application uses libraries such as : gtk3, libsndfile, libttspico … It works well on my first system and now I want to compute a snap package to distribute it. As Linux Mint does not like snaps I copied the sources code and all the needed files on my second system “Ubuntu 20.04”. I did not installed the libraries on that second system as they are not needed to build a snap. I have written the following yaml file which uses core18 and may have bugs :

##################### start of .yaml file #########################

name: furch-diaoulek
base: core18 #added (found on the web) 
version: "2.04.00"
summary: a snap for the Furch-Diaoulek software
description: GNU Furch-Diaoulek.
  This software will help you to learn languages of the western world
  which may be transcribed with a Latin-1 coding.
  It is a vocabulary manager and an assistant to read texts.
  It works mainly for Breton->French but also for English->French
  and may be used for other languages.
  The software may use the Svox-pico speech synthesis code. 
  You have documentation at http //furchhadiaoulek.free.fr 
confinement: strict
grade: stable

icon:  ./D2-04/FURCH-DIAOU.png #does not seem to use it
#adapter: none #  trial !
apps:
    fdiaou:
                command: diaou.x # nécessaire et OK but command unknown !
                extensions: [gnome-3-28]
                plugs:
                  - home
                  - audio-playback
                    #                slots:
                    # - dbus-daemon
#              daemon: simple
 #               adapter: none  #trial
parts:
   fdiaou:

     plugin: make
     makefile: makediaou-snap # This is the name of my Makefile for compilation
     artifacts: [.] # Why that line ?
     build-packages: 
       - make
       - gcc
       - pkg-config
       - libsndfile1-dev
       - libasound2-dev
       - libcurl4-openssl-dev
       - libttspico-utils
       - libttspico-dev
       - libmpg123-dev
       - libmp3lame-dev
       - libsamplerate0-dev
     stage-packages: 
       - libcurl4
       - libmpg123-0
       - libsndfile1
       - libasound2
       - libttspico-utils
       - libttspico0
       - libttspico-data
       - libcurl3-nss
       - libcurl3-gnutls
       - libnspr4
       - libnss3
       - libmp3lame0
       - libsamplerate0

     source-type: hg  # I am using Mercurial as a local versioning tool
     source: ./D2-04/ # Where code, makefile, and hg files are

##################### end of .yaml file #########################

I have launched the snap compilation with : snapcraft clean --use-lxd snapcraft build --use-lxd snapcraft stage --use-lxd snapcraft --use-lxd Each step was OK even without warnings and the snapfile : furch-diaoulek_2.04.00_amd64.snap was created. However this snap must be tested :

sudo snap install --dangerous furch-diaoulek_2.04.00_amd64.snap

Everything seems OK and a directory /snap/furch-diaoulek/x1 is created. This directory contains the executable diaou.x I try launching the application with the command : /snap/furch-diaoulek/x1/diaou.x It fails with the following response : /snap/furch-diaoulek/x1/diaou.x: error while loading shared libraries: libttspico.so.0: cannot open shared object file: No such file or directory

However “libttspico.so.0” as well as many other .so files are into : /snap/furch-diaoulek/x1/usr/lib/x86_64-linux-gnu So there is clearly a PATH problem with this snap. Even stranger : I have installed and launched the snap on my first system with the same commands. This system is the one used to develop the application and everything with the installed snap runs well ! The executable diaou.x is able to use libttspico.so.0 and all the other libraries ! I know, all the libraries are also installed on this OS but the snap should be strictly confined and not able to use libraries outside its own sandbox, no ? So I have 2 questions : 1) Why my snap is working on one OS and not on the other ? 2) How to tell a snap to search libraries in /snap/snap_name/current/usr/lib/x86_64-linux-gnu ?

Any comment on that subject would be greatly appreciated. Many thanks in advance…

if you put three backticks ``` above and below your snapcraft.yaml paste, the forum software makes sure the yaml formatting does not get lost like it currently is … that will help a lot so people can actually read your yaml :slight_smile:

backticks have been put above and below the yaml file I hope it helps. And thank you for your reply, I am new to this forum

1 Like

You are launching your application wrong. The correct command to execute is either of:

/snap/bin/fdiaou

# OR

snap run fdiaou

# OR, if /snap/bin is included in your PATH environment variable (on Ubuntu this is set up for you)

fdiaou

By calling /snap/furch-diaoulek/x1/diaou.x directly, you’re completely sidestepping snapd and the confinement and other setup that it does for you.

Thank you very much, it is almost that ! Looking at /snap/bin, I have into that directory the executable diaou.x and the link furch-diaoulek.fdiaou

  1. /snap/bin/fdiaou does not work
  2. /snap/bin/diaou.x tries to start but results in a segmentation fault due to the way I have concieved the application -it does not find its data files. Otherwise it should have worked…
  3. the command : furch-diaoulek.fdiaou works fine !
  4. the command : snap run furch-diaoulek.fdiaou is also good
  5. the command /snap/bin/furch-diaoulek.fdiaou is also OK

Your remark that by the command /snap/furch-diaoulek/x1/diaou.x I was completely sidestepping the confinement explains why it was working on the first OS where the libraries were installed and why it was not working on the second OS without the libraries.

Congratulation, you solved the problem !

2 Likes