I had a running snap for my program, until I changed confinement and the place where some data is saved. I used to save it in the current directory but since this changes to where the user decides to start the program I decided to save the data file into something more appropriate:
/home/user/.local/share/myapp/file
I asked in askubuntu if I had to use the home plug to achieve this and I was told I didnât.
But now my snap tries to save all the user home subdirs (downloads, Images, etc) but itâs not allowed and then it crashes with this error:
GLib-GIO-ERROR **: No GSettings schemas are installed on the system
Trace/breakpoint trap (imagem do nĂșcleo gravada)
Iâm completely clueless about this error any help wold be welcome.
Thanks
Typically you must either 1) use the home interface to get access to some parts of the home directory (except for dot files), use 2) XDG_DATA_HOME that is derived from $HOME which snapd changes or 3) use $SNAP_USER_DATA and $SNAP_USER_COMMON where snapd will manage your applicationâs data across revisions.
This was running the snap on 17.10, so I donât know if that is a related issue or not. The script did symlink and compile the schemas, so that particular part of the script seems to be functioning correctly.
Looking through the glib NEWS file, I did stumble on this though:
Overview of changes in GLib 2.53.2
==================================
...
* GSettings now consider XDG_DATA_HOME in addition to XDG_DATA_DIRS.
...
However, Ubuntu 16.04 shipped with an older version of GLib. As one of the cleanups in my PR, I removed $XDG_DATA_HOME from $XDG_DATA_DIRS on the basis that the spec said having it there was superfluous. I suspect adding it back will fix the problem youâre seeing, so Iâll put together a followup PR.
I think I missed this when testing apps using the gnome-platform snap because they ship a newer GLib.
Iâve put up a new pull request that should fix this if Iâve correctly identified the root cause:
The easiest way to test this would probably be to run snapcraft prime, then manually make the change from the PR to prime/bin/desktop-launch and finish building the package. If that works for you, weâll get the change merged ASAP.
My program now works on Ubuntu 16.04. The snap still tries to create default user directories when it starts but after, it runs well. Iâve tested it on Ubuntu 17.10 and it gives the segmentation fault you showed. I wonder if I have to use the desktop-gnome-platform part to avoid this error on 17.10.
Note that if youâre hardcoding ~/.local/share as the directory under which you store your data youâre doing it wrong even without considering snaps. ~/.local/share is the default value of XDG_DATA_HOME; youâre supposed to check that first as itâs possible to have it pointing elsewhere (and I know people that do).
Thereâs not much we can do about that use case though: a sandboxed app is only going to be able to access those directories the AppArmor profile allows, and that profile canât take per-user (or more accurately per-process) environment variables into account.
Maybe this is something we could address in the future via user mounts (e.g. make sure $XDG_DATA_HOME is mounted at ~/.local/share inside the sandbox), but for now I think having a 99% solution is useful.