tl;dr - desktop helpers don’t seem to setup XDG_DATA_DIRS correctly. May only be of interest to @kenvandine
Over the weekend I took a look at snapping a funky desktop elementary OS presentation application called Spice-Up. The application makes nice presentations, and as with most elementary OS apps, is written in vala.
I click “New presentation”:
I get this in the console:
[FATAL 18:33:48.997449] file /root/build_spice-up/parts/spice-up/src/src/Services/FileManager.vala: line 100: uncaught error: Failed to create file '/home/alan/(null)/Untitled Presentation 1.spice.1B7C7Y': No such file or directory (g-file-error-quark, 4)
Note: “(null)” is due to it not being able to figure out my “Documents” directory name.
I had to do a few nasty things to get the required elementary libraries required to get the snap working, lets gloss over that bit in this thread ;). The issue I have is that the application uses the vala get_user_special_dir to obtain the localised “Documents” directory, in which to create the presentation. This fails (details below) which uncovered a bug in the application which doesn’t do the right thing when the XDG_DATA_DIRS aren’t setup right.
I’m sure they’ll fix that, but the more pressing thing for me is that the directories aren’t setup in the first place.
XDG_DATA_DIRS=/home/alan/snap/spice-up/x1/.local/share:/home/alan/snap/spice-up/x1:/snap/spice-up/x1/usr/share:/usr/share/ubuntu:/usr/share/gnome:/home/alan/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
As far as I can tell, the location this points to should contain user-dirs.dirs
and user-dirs.locale
but they don’t. On my non-snap home directory those files are in ~/.config as expected. But when the snap is run, it doesn’t see that directory (the home plug blocks hidden directories) and the .dirs files don’t exist inside the $SNAP_USER_DATA
environment.
Should the desktop helpers set these up?
Here’s my yaml. Only run this in cleanbuild - it adds PPAs, you don’t want that.
name: spice-up
version: '1.0.0'
summary: Create simple and beautiful presentations on the Linux desktop
description: |
Spice-up is a modern and intuitive desktop presentation app based
upon SpiceOfDesign's presentation concept. Built from the ground up
for elementary OS, it gives you everything you need to create simple
and beautiful presentations.
grade: stable
confinement: devmode
apps:
spice-up:
command: desktop-launch $SNAP/bin/com.github.philip-scott.spice-up
plugs:
- x11
- unity7
- home
- gsettings
- pulseaudio
- opengl
- network
parts:
elementary:
plugin: nil
prepare: |
add-apt-repository -y ppa:elementary-os/stable
add-apt-repository -y ppa:elementary-os/os-patches
echo "Package: *" > /etc/apt/preferences.d/elementary-stable
echo "Pin: release o=LP-PPA-elementary-os-stable" >> /etc/apt/preferences.d/elementary-stable
echo "Pin-Priority: 1000" >> /etc/apt/preferences.d/elementary-stable
echo "Package: *" > /etc/apt/preferences.d/elementary-patches
echo "Pin: release o=LP-PPA-elementary-os-os-patches" >> /etc/apt/preferences.d/elementary-patches
echo "Pin-Priority: 1000" >> /etc/apt/preferences.d/elementary-patches
apt update
apt dist-upgrade -y
spice-up:
after: [elementary, desktop-gtk3]
plugin: cmake
source: https://github.com/Philip-Scott/Spice-up.git
source-tag: '1.0.0'
build-packages:
- build-essential
- gettext
- libgee-0.8-dev
- libgtk-3-dev
- valac
- libgranite-dev
- libjson-glib-dev
- libgudev-1.0-dev
- libevdev-dev
organize:
share/glib-2.0: usr/share/glib-2.0