How to expose $SNAP_COMMON/usr/share/[game]/ as /usr/share/[game]/

Hi
I’m snapping a game engine that relies on some external proprietary data. I was wondering how to expose $SNAP_COMMON/usr/share/[game]/ as /usr/share/[game]/
to my application? snap doesn’t seem to do this by default when I copy the files manually.

You cannot make your application “imagine” that the files are in the normal location yet. That is coming in a future update to snapd, and is being worked on now. You might find that the game engine supports an override via either an environment variable or a command-line flag. If it supports that then you can do one of the following, depending on which it supports:

environment

apps:
  my-game-engine:
    ...
    environment:
      OVERRIDE_FILE_VARIABLE_NAME: $SNAP/usr/share/my-game

command-line

apps:
  my-game-engine:
    ...
    command: path/to/executable --override-files-flag=$SNAP/usr/share/my-game
1 Like

It’s been a while since I looked at this topic. and it seems that snap has made some improvements since. Am I correct in thinking that the new mapping functionality will solve my issue?

You can now make your snap see the game files in the correct location with the snapd feature we’re calling “layouts”:

...

base: core # this is needed to enable the new functionality
# `core` is the original 16-series based on Ubuntu 16.04 and core18 is the 18-series based on Ubuntu 18.04

layout:
  /usr/share/<insert your folder name>:
    bind: $SNAP/usr/share/<insert your folder name>

parts:
  ...

apps:
  ...
1 Like