Where to store config files

I am confused about $SNAP_COMMON and $SNAP_USER_COMMON. According to doc, $SNAP_COMMON is writable by root. I need to store a small config file (text format) which will be writable by application and will persist across versions. Is $SNAP_USER_COMMON my best bet? There’s also $SNAP_SAVE_DATA that mentions config files in the documentation: https://snapcraft.io/docs/environment-variables

Please advise.

SNAP_DATA and SNAP_COMMON are for daemon snaps, don’t bother unless you’re snapping a background service.

For user applications, SNAP_USER_DATA is your best bet, as content saved by old revisions of the snap is backed-up and preserved during snap refresh and can be rolled back by the user if it breaks the new revisions of the application. This is also why it is the HOME directory in the snap runtime.

If you don’t care about compatibility you can also place it in the SNAP_USER_COMMON directory.


Thank you for very clear explanation. I wish the official doc was just as detailed and clear.

1 Like

If I may add, I believe that $SNAP_USER_COMMON is removed when the snap is uninstalled. This is different than “uninstalling” an apt package and more like “purging” an apt package. Things may have changed since I looked though. This was not apparent to me just from the documentation and required some experimenting to confirm.

1 Like

The documentation is available for everyone to edit, feel free to improve it :slight_smile:

1 Like

Thanks for the updates and extra context here. I’'ll happily update the docs to make this clearer; and yes, everyone is free to add and edit things. It all helps!

1 Like