I have a python app that creates a tmp directory using TemporaryDirectory() to store a backup dump.
After creating the snap and test it I can see that it obviously fails as the snap doesn’t have access to /tmp folder.
Here is the part of the source code that creates and manages the temporary directory.
What is the best way to manage temp files/folders with snapcraft?
I’m thinking I need to implement something as generic as possible, as the app can be either installed using snap or manually compiled from source using python outside the snap scope.
Snaps should have free access to /tmp but you should keep in mind that each snap has a private view of that directory. Can you please tell me what the problem was, specifically, in your case?
By taking a more in depth look it seems the app is failing not at creating the temp folder but rather when trying to run the command pg_dump, particularly at this line.
Is there any reason snap may be preventing this command to run?
It looks like you may have additional missing requirements. pg_dump is trying to access a shared library out side of the snap. feb 28 13:46:19 martin-VirtualBox audit[17944]: AVC apparmor="DENIED" operation="file_mmap" profile="snap.yorokobi.daemon" name="/usr/lib/x86_64-linux-gnu/perl-base/auto/Fcntl/Fcntl.so" pid=17944 comm="pg_dump" requested_mask="m" denied_mask="m" fsuid=0 ouid=0
I’m pretty sure this library is not provided by the core snap. Have you tried running snappy-debug? I’ve found it very helpful for diagnosis these types of problems.