Temporary «data» files for install


I’m wondering if there’s an option to store data in the snap package that is not stored in the $SNAP folder. Typically this is config files that is shipped along with the software.

Lets say Nginx is shipped with the folder containing the default settings for /etc/nginx. But since /etc/nginx needs to be non-existent for layouts have write access under $SNAP, this folder cant be stored in $SNAP/etc/layout.

Also keeping the folder in $SNAP/etc/nginx (or somewhere “hidden” under the $SNAP hierarchy, for less confusion) and copy it into $SNAP_DATA upon installation seems like waste of space. You’ll then end up with duplicates… and more space is used.

So… is there anywhere in the .snap-package these defaults can be stored, so when the user have installed the app, it’s copied from the snap to the designated place. The original is not under $SNAP or $SNAP_DATA, but will get deleted if the user decides to delete the .snap package?

Let me know if it’s unclear what I meant :slight_smile:

Well as you mention the most natural place to store the default values is indeed in $SNAP and this is what pretty much all snaps do. There is no location under $SNAP that your snap can have available to it that will be writable but still persist after the user removes the snap. One alternative I think some snaps do is to download some files manually, in which case you don’t need to ship them with the snap, but then they need to be hosted somewhere which is costly.

With regards to the location to store them so that they are persisted, all of the data under $SNAP_USER_COMMON and $SNAP_USER_DATA will be persisted after the snap is removed. Users can also benefit from $SNAP_DATA being backed up via the auto-snapshot system, so even if you choose to store this data in $SNAP_DATA and it gets “deleted” after the user removes the snap, they could still restore the automatic snapshot and get their data back that way.


Yes, this is how I’m doing it today, and it’s not a question on where to store the two copies. I consider it waste of space of having the original stored in $SNAP-directory and the writable version in $SNAP_DATA. It would have been nice having a directory within the snap-package that only contained «temporary data» that could be stored on installation, and then the original would be deleted whenever the snap-package file will.

Also downloading this while installing doesn’t seem like the best option to me, as you require the device to have internet to successfully install it. Some devices might have restricted internet connectivity and only operate on a local network.