Snap works on one machine but not on another

I’ve built my first snap (clementine-snap) and on one machine it works without flaw, as intended. On another machine, hmmm.

There’s a problem with missing libraries, which are called out in the yaml and don’t create a problem with machine 1. Machine 2, the app must be run via terminal (which is good as I can see the issues arise during startup) but the snap fails to load sometimes and crashes others.

BTW, both machines are Ubuntu 16.04.3 (Unity).

I am a bit confused as I am new to snapcrafting. Thanks in advance.

1 Like

Sounds like the snap is missing a few things that it’s able to find on Machine 1, but not Machine 2. I suggest you either use cleanbuild (snapcraft cleanbuild) which runs in a clean lxd container, or create a clean container yourself and run snapcraft within it. That will help tease out any libraries you’re missing in the YAML.

3 Likes

Also might want to paste the output of it working vs failing. If you post the yaml we can also test it.

3 Likes

You’re both right, it’s definitely deps.

Here’s a copy of my yaml (and thanks in advance BTW):

name: clementine-snap # check to see if it's available
version: '1.3.1.3' # check the version number of clementine's packages
summary: Clementine is a modern music player. # 79 char long summary
description: |
  Clementine is a modern music player and library organizer for Windows, Linux and Mac OS X.

grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  clementine:
    command: bin/clementine
    plugs:
      - network

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: cmake
    build-packages:
       [liblastfm-dev,libtag1-dev,gettext,libboost-dev,libboost-serialization-dev,libqt4-dev,qt4-dev-tools,libqt4-opengl-dev,cmake,libgstreamer1.0-dev,libgstreamer-plugins-base1.0-dev,libglew1.5-dev,libqjson-dev,libgpod-dev,libplist-dev,libusbmuxd-dev,libmtp-dev,libcdio-dev,protobuf-compiler,libprotobuf-dev,libcrypto++-dev,libfftw3-dev,libsparsehash-dev,libsqlite3-dev,libpulse-dev,libqtwebkit-dev,libechonest-dev,libchromaprint-dev,libqca2-dev]
    source-type: git
    source: https://github.com/clementine-player/Clementine
   
    install: |
      cd bin
      cmake ..
      make -j10
      sudo make install

Thanks for that. For future reference it’s easier for others to copy your yaml off the page if you wrap it in code tags (3 backticks), just highlight the code and press CTRL+Shift+C (I think). The first thing I’d do is remove sudo from the last line and try and build in a clean container. So setup lxd sudo snap install lxd, sudo lxd init, then once lxd is setup you should be able to snapcraft cleanbuild. I’m trying that here but I’m at conference with slow wifi so it’s taking ages. Alternatively, throw your code in github and use http://build.snapcraft.io/ to build it for you :slight_smile:

You do not define any stage-packages … (runtime dependencies) only build-packages. so none of the dependencies will be included in your snap, it is actually very curious that it runs on one machine (if the defined strict confinement works right it should not run at all and complain about missing libraries). how do you run your snap when it actually works ?

1 Like

The lack of stage-packages is actually probably mostly okay due to Snapcraft’s ldd crawling. But certainly something is missing.

Thanks for that. I am confused, too. Mainly because this is the first time I’ve ever built a snap.

I will look into the stage-packages.

Honestly, when I finished this version of the yaml, I was shocked that it actually worked! So, I got excited and published it.

That’s when I discovered the error.

Here’s a video of the snap in action on the machine that can use it…

https://youtu.be/NnL7x1TP6iA

Is there someplace I can read up about and create an lxd container?

Thanks again Popey, I added my github to build.snapcraft.io.

This too: clementine-snap

These are the NEW errors after creating a new YAML with the stage-packages:

cc1plus: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
cc1plus: error: unrecognized command line option ‘-Wno-unused-private-field’ [-Werror]
cc1plus: all warnings being treated as errors
src/CMakeFiles/clementine_lib.dir/build.make:5560: recipe for target 'src/CMakeFiles/clementine_lib.dir/engines/gstengine.cpp.o' failed
make[2]: *** [src/CMakeFiles/clementine_lib.dir/engines/gstengine.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:833: recipe for target 'src/CMakeFiles/clementine_lib.dir/all' failed
make[1]: *** [src/CMakeFiles/clementine_lib.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Command '['/bin/sh', '/tmp/tmpvh6cyarp', 'make', '-j4']' returned non-zero exit status 2

Here’s the new YAML:

name: clementine-snap # check to see if it's available
version: '1.3.1.5' # check the version number of clementine's packages
summary: Clementine is a modern music player. # 79 char long summary
description: |
  Clementine is a modern music player and library organizer for Windows, Linux and Mac OS X.
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  clementine: 
    command: bin/clementine
    plugs:
      - network
      - home
      - pulseaudio
    
parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: cmake
    build-packages:
       [liblastfm-dev,libtag1-dev,gettext,libboost-dev,libboost-serialization-dev,libqt4-dev,qt4-dev-tools,libqt4-opengl-dev,cmake,libgstreamer1.0-dev,libgstreamer-plugins-base1.0-dev,libglew1.5-dev,libqjson-dev,libgpod-dev,libplist-dev,libusbmuxd-dev,libmtp-dev,libcdio-dev,protobuf-compiler,libprotobuf-dev,libcrypto++-dev,libfftw3-dev,libsparsehash-dev,libsqlite3-dev,libpulse-dev,libqtwebkit-dev,libechonest-dev,libchromaprint-dev,libqca2-dev]
    source-type: git
    source: https://github.com/clementine-player/Clementine
    stage-packages: 
      - liblastfm-dev
      - libtag1-dev
      - gettext
      - libboost-dev
      - libboost-serialization-dev
      - libqt4-dev
      - qt4-dev-tools
      - libqt4-opengl-dev
      - cmake
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libglew1.5-dev
      - libqjson-dev
      - libgpod-dev
      - libplist-dev
      - libusbmuxd-dev
      - libmtp-dev
      - libcdio-dev
      - protobuf-compiler
      - libprotobuf-dev
      - libcrypto++-dev
      - libfftw3-dev
      - libsparsehash-dev
      - libsqlite3-dev
      - libpulse-dev
      - libqtwebkit-dev
      - libechonest-dev
      - libchromaprint-dev
      - libqca2-dev

    install: |
      cd bin
      cmake ..
      make -j10
      sudo make install

You most likely do not want the -dev versions of the libraries in stage-packages (while a -dev usually depends on the binary lib, this will just make your snap big, better look up the actual binary package names and use these)

Why are you calling cmake and make in the install scriptlet (i think the cmake plugin actually calls cmake in the build step (before install) so this should not be needed)

Ogra,

Honestly, I don’t know what I’m doing…this is ALL new to me.

In terms of the packages, these are the deps listed in the original Clementine repo for building from source, so…there you go.

The install scriplet is also from the Clementine repo.

Here’s the thing, it built and is running on this machine (as seen in the video) which is beyond me. There aren’t any errors.

I am not able to get to another device to test the new builds out and see what’s happening.

EDIT: I’ve removed the scriplet and I’m attempting the build without it. Crossed-fingers…

Hmm, are you sure you do not have the Clementine deb installed and are actually running this ?

Your video shows a lot of desktop integration (notifications, the indicators etc) but none of your yaml’s actually has the necessary interfaces enabled in the apps section… To me this looks like you have the deb installed on the machine shed it works and are accidentally executing that one ( no worries happens to me too all the time when snapping something I also use regular :wink: )

Try using “snap run clementine” from a terminal instead or start it via /snap/bin/clementine …

No, I don’t have the deb installed. In fact, the first three attempts to build the snap resulted in the typical: clementine is not installed blah blah, to install sudo apt install …

It’s running from the snap.

But look at the output of issuing an apt install command. I wonder if the needed deps were installed on my system during the initial builds of the previous snaps up to now…

Yep, that’s why it’s working on this machine! It was the deps. I didn’t install them (purposely) on this machine. Could the yaml have called pulled them down to this machine during the build?

I just tried to open clementine and it failed (see pic).

EDIT:

Here’s a NEW pic of another attempt to build from an edited YAML calling on the same deps listed during the sudo apt install clementine output:

Am I missing something from “STAGE”?

For a GUI application, you probably want to include x11 in your plugs, potentially unity7 (unity7 plug enables access to things like the indicator mechanism, though you still need the libindicator installed to actually use it. unity7 plug will be replaced with desktop in the future - possibly for snapd 2.28)

the cmake plugin will run cmake from an appropriate build directory pointing the command at your source, so you do not need to manually run that. Then it will perform make and make install so you don’t want to do those, yourself either. To specify cmake build flags you can add them in your part definition under configflags: which takes an array, so format similarly to:

parts:
  my-part:
    plugin: cmake
    configflags:
      - '-DCMAKE_INSTALL_PREFIX=/usr'
      - '-DAnotherBuildFlag'
      - foobar

You do not want to include the source location, e.g. .. or similar, part of the cmake command in configflags.

The -dev packages need to be in build-packages: or your build probably won’t be able to find them, or if it can it is purely by luck/chance. build-packages are installed into the host system before running the plugin’s build process, which for the cmake plugin is cmake .., make -j<#procs>, and make install. The stage-packages are not installed into the host system, but are unpacked into your snap’s filesystem so that the snap can find them at runtime.

Finally, for a QT4 application you probably want to add after: [desktop-qt4] so that snapcraft pulls down and creates a desktop-launch script which you can use to handle the declaration of runtime library locations. You would change your apps config to something similar to below to use the launcher script:

apps:
  clementine:
    command: desktop-launch $SNAP/bin/clementine
    plugs:
      - ...
1 Like

Thanks daniel! This is great. I’ll get started on this right away. fingers crossed!