Copy file into HOME folder on install snapcraft

I would like to copy one specific config file to the users HOME folder upon install and would like to be able to access this file for read-write access while the program executes. How could I go about that?

You need to ask nicely in store-requests and when granted add personal-files to snapcraft.yml as described in documentation. Adding and releasing snap before getting approved will trigger manual review.

NOTE: Usually these are used to import existing configuration files into snap directories (read-only) not for keeping configuration files outside snap directories. Snapshots preserve all files in snap directories so you don’t have to keep them outside.

Even with personal-files, doing user-specific work from the install hook is problematic since snaps are installed system wide. Which user’s home folder? What if a user is created after the snap is installed?

For per-user data, you’re probably better copying the file when your command is run (if it is missing).

I consider Jamesh’s answer combined with personal-files to be suitable, so thank you for your answers

1 Like