Got stuck with my first snap, game does not run

Hi all. As it is my first post I hope I have placed it in the correct spot.

I want to help publish Battle for Wesnoth game in the Snap store. I have learned basics. I have learned how plugs works, how to provide build and runtime dependencies.

I got the game to compile and Snap was built, but when I execute the game after Snap install it gives no error but rather returns to the shell. How can I debug this?

Here is my current yaml:

name: battle-for-wesnoth
base: core22
version: '1.18.0'
summary: A turn-based strategy game with a high fantasy theme
description: |
  Build up a great army, gradually turning raw recruits into hardened
  veterans. In later games, recall your toughest warriors and form a
  deadly host that no one can stand against! Choose units from a large
  pool of specialists, and hand-pick a force with the right strengths
  to fight well on different terrains against all manner of opposition.

  Wesnoth has many different sagas waiting to be played. Fight to regain
  the throne of Wesnoth, of which you are the legitimate heir... lead a
  brutal quest to unite the orcish tribes... vanquish a horde of undead
  warriors... Guide a band of elvish survivors in an epic quest to find
  a new home...

  There are at least two hundred unit types, sixteen races, six major
  factions, and hundreds of years of history. The world of Wesnoth is
  absolutely huge and only limited by your creativity. You can also
  challenge up to eight friends — or strangers — and fight in epic
  multiplayer fantasy battles.

grade: stable
confinement: devmode # use 'strict' once you have the right plugs and slots

parts:
  wesnoth:
    # See 'snapcraft plugins'
    plugin: cmake
    cmake-parameters:
      - ".. -DCMAKE_BUILD_TYPE=Release"
    source: https://github.com/wesnoth/wesnoth.git
    source-branch: 1.18
    build-packages:
      - libboost-all-dev
      - libsdl2-dev
      - libsdl2-image-dev
      - libsdl2-mixer-dev
      - fontconfig
      - libcairo2-dev
      - libpangocairo-1.0-0
      - libpango1.0-dev
      - libvorbis-dev
      - libbz2-dev
      - libz3-dev
      - libssl-dev
      - libcrypto++-dev
      - libcurl4-openssl-dev
      - libdbus-1-dev
      - libreadline-dev
    stage-packages:
      - libopusfile0
      - libflac8
      - libsdl2-2.0-0
      - libsdl2-image-2.0-0
      - libsdl2-mixer-2.0-0
      - libboost-filesystem1.74.0
      - libboost-iostreams1.74.0
      - libboost-locale1.74.0
      - libboost-program-options1.74.0
      - libboost-random1.74.0
      - libboost-regex1.74.0
      - libboost-thread1.74.0
      - libcairo2
      - libcurl4
      - libdatrie1
      - libdeflate0
      - libfluidsynth3
      - libfontconfig1
      - libfribidi0
      - libgomp1
      - libgraphite2-3
      - libharfbuzz0b
      - libicu70
      - libicu70
      - libicu70
      - libinstpatch-1.0-2
      - libjack-jackd2-0
      - libjbig0
      - libjpeg-turbo8
      - libldap-2.5-0
      - libldap-2.5-0
      - libmodplug1
      - libmpg123-0
      - libnghttp2-14
      - libpango-1.0-0
      - libpangocairo-1.0-0
      - libpangoft2-1.0-0
      - libpixman-1-0
      - libpsl5
      - librtmp1
      - libsasl2-2
      - libthai0
      - libtiff5
      - libvorbisfile3
      - libwebp7
      - libxcb-render0
      - libxcb-shm0
      - libboost-context1.74.0
      - libboost-coroutine1.74.0
      - libboost-filesystem1.74.0
      - libboost-iostreams1.74.0
      - libboost-locale1.74.0
      - libboost-random1.74.0
      - libboost-thread1.74.0
      - libicu70
      - libicu70
      - libicu70
      - libpulse0

apps:
  battle-for-wesnoth:
    environment:
      LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$SNAP/usr/lib/
    command: /usr/local/bin/wesnoth
    plugs:
      - opengl
      - network
      - network-bind
      - pulseaudio
      - x11
      - desktop
      - home
      - removable-media

At a guess, you’re shipping the game runtime, but not the datafiles. So when you launch the game, it crashes because it can’t find the data for the game.

There’s also duplicate libraries listed in your stage-packages, so I’m surprised this builds at all, because for me, snapcraft won’t build with duplicate lines there.

Also, the command line should probably not start with a leading slash, but be usr/local/bin/wesnoth.

+1 on @popey’s advice.

There are some different ways to debug snaps documented here. snap run --debug could be useful here - you can try launching the game and troubleshooting within the snap’s environment.