I'm currently working on a server side app written in Golang. I want to package the app in a snap package.

Where can I store a global configuration file for the app that retains itself even after an upgrade?

Some sample code would be nice, thanks!


All info you need regarding where snap can read/write files can be found in this post: Where can Ubuntu snaps write data?

From your question it seems you will be most interested in SNAP_COMMON folder.

  • 2
    Where is the SNAP_COMMON folder? Is SNAP_COMMON an environmental variable?
    – Evan Lin
    Apr 17 '17 at 20:59
  • 2
    it's env variable but only valid from within the snap. You will not be able to get it from the system itself as it is snap dependent. To get it run your snap as 'snap run --shell <your snap name>'. You can run 'env | grep SNAP' once inside and see proper location of SNAP_COMMON folder. It should be like this: 'SNAP_COMMON=/var/snap/<your snap name>/common'
    – Jasko
    Apr 18 '17 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.