I am trying to snap a cryptocoin Qt wallet as an exercise. The application doesn’t matter but I’ll use it as an example since it’s not “snap aware”.
When you bootstrap the wallet you choose your data directory (where it will download the blockchain to):
[X] Use the default data directory <-- default, doesn't work, outside of the snap tree
[ ] Use a custom data directory <-- works, inside the snap directory
The default option would only work by having the snap in classic confinement. This means I have two options: a classic snap or a snap that’s half working and you need to RTFM before using it. The first has the best UX, the second follows the “snap rules” and has the confinement advantages.
What is the best course of action here? Is there a way of showing a message at first boot explaining the default option will not work?
Where does it actually try to write the default data directory? Is it hard-wired somehow to put it in a hidden directory in your home?
I’ve had some success by setting $HOME in the environment stanza for the application. Cryptocurrencies specifically it’s worth coercing because the blockchain can be a chunky amount of data. The default $HOME for a snap is in the versioned $SNAP_USER_DATA (/home/user/snap/snapname/current) but might be better placed in the unversioned $SNAP_USER_COMMON (/home/user/snap/snapname/common).
Often this is sufficient to make the app put its data in the right place.
Might be worth looking at the source for the application and see how it derives the “default data directory”. If it’s trying to be ‘clever’ and put it in the host $HOME/.somefolder then that will fail. Might need patching either locally or as a contribution to the upstream project (in the best case).