How to know which layouts are needed?

I’m currently trying to snap my first application.
It’s an old Windows game called Re-Volt which got a Linux port from the community (https://re-volt.io/).
Since the game is intended to be run on Ubuntu 18.04 and I’m running 20.04 I needed to do some tweaking in order to get it working which lead me to the idea that this would be ideal to be snapped.
Thanks to the tutorials by @popey and the documentation I was able to create something working.
At the moment you can play the game but it isn’t possible to save anything.

I tried to add a layout for the profiles folder which seems to hold the saves in my non-snap version.
How would one debug which layouts are needed? The output of snappy-debug wasn’t really that useful for this.

INFO: Following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug
= AppArmor =
Time: Feb 22 21:25:59
Log: apparmor="ALLOWED" operation="open" profile="snap.re-volt.re-volt" name="/home/andreas/.config/ibus/bus/4d86c2c4aaa24452b0459603f07e929c-unix-0" pid=191305 comm="rvgl.64" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /home/andreas/.config/ibus/bus/4d86c2c4aaa24452b0459603f07e929c-unix-0 (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* add one of 'desktop-legacy, unity7' to 'plugs'

= AppArmor =
Time: Feb 22 21:25:59
Log: apparmor="ALLOWED" operation="connect" profile="snap.re-volt.re-volt" pid=191305 comm="rvgl.64" family="unix" sock_type="stream" protocol=0 requested_mask="send receive connect" denied_mask="send connect" addr=none peer_addr="@/home/andreas/.cache/ibus/dbus-CcaV8fsN" peer="unconfined"

= AppArmor =
Time: Feb 22 21:25:59
Log: apparmor="ALLOWED" operation="file_perm" profile="snap.re-volt.re-volt" pid=191305 comm="rvgl.64" family="unix" sock_type="stream" protocol=0 requested_mask="send receive" denied_mask="send" addr=none peer_addr="@/home/andreas/.cache/ibus/dbus-CcaV8fsN" peer="unconfined"

= AppArmor =
Time: Feb 22 21:26:00
Log: apparmor="ALLOWED" operation="open" profile="snap.re-volt.re-volt" name="/etc/openal/alsoft.conf" pid=191305 comm="rvgl.64" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/openal/alsoft.conf (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)
* add 'system-files (see https://forum.snapcraft.io/t/the-system-files-interface for acceptance criteria)' to 'plugs'

What is the full path on your desktop where it saves files currently in the non-snap version?

It saves them directly in the game directory.
When you run the installer it asks for a path and then downloads all the files to that path.
The saves then get saved inside the profiles folder.

E.g.
/home/user/programmes/revolt/profiles where /home/user/programmes/revolt/ contains the other game files as well.

unless your snap runs as daemon you want:

layout:
  $SNAP/re-volt/profiles:
    bind: $SNAP_DATA/profiles

to be:

layout:
  $SNAP/re-volt/profiles:
    bind: $SNAP_USER_DATA/profiles
1 Like

I agree that this would make sense according to the documentation, however when I try it, I get the following error:

Failed to create snap, snap command failed:
stdout:

stderr:
error: cannot pack "/root/prime": cannot validate snap "re-volt": layout "$SNAP/re-volt/profiles" uses invalid bind mount source "$SNAP_USER_DATA/profiles": reference to unknown variable "$SNAP_USER_DATA"

I released the app to the store on the edge channel in case someone wants to test it without having to build it.

Unfortunately layouts cannot use user-specific paths at the moment, so $SNAP_USER_DATA and $SNAP_USER_COMMON are unusable.

What would be the proper solution?