How to persist user config data to SNAP_USER_DATA?

the install hook runs as root so this would just install the config into SNAP_USER_DATA in roots homedir (/root) …

if you really need to pre-create the file (does the app not work if it is not existing ?) i’d suggest using a wrapper script like:

#! /bin/sh

[ -e "$SNAP_USER_DATA/config.toml" ] || touch $SNAP_USER_DATA/config.toml

exec "$@"

ship it in bin/ inside your snap and change your command: entry:

from:

apps:
  myapp:
    command: myapp

to:

apps:
  myapp:
    command: mylauncher.sh myapp

(or you could use a command chain)

well, then just make your app read and use the environment variable when handling the config file …