Shell script as snap can write to /tmp but not read?

I am trying to turn a shell script that builds Ubuntu images into a snap. One of the things the script does is create a tarball on the host and then push it into a lxd container.

When run as a snap, the creation of the tarball happens correctly – the tarball is written to the expected location. However, when there’s an attempt to read the tarball, via a lxc file push command, the snap/script can’t find the file. See this pastebin for a tail of the error: https://paste.ubuntu.com/p/tnDHYFnmnX/

It seems very odd to me that the snap can write to /tmp, but cannot seem to read from it.

Any suggestions? I am certainly a snap novice; maybe there’s something obviously wrong about my .yaml file.

For reference, the shell script/project, along with my attempt at a snapcraft.yaml is here: https://github.com/codyshepherd/ubuntu-old-fashioned/tree/snap

Note that this is a public forum. Please consider using a public paste utility, perhaps https://paste.ubuntu.com/ .

Any chance you have LXD installed as a snap? When snaps use /tmp they actually get an isolated slice of the real (i.e. the host’s) /tmp, which means snaps can’t access each other’s /tmps.

Also note that if the shell script which is putting the tarball into /tmp is strictly confined it will have a different /tmp than the host too, but that’s the effectively the same problem as running LXD as a snap…

I’ve tried using the apt package version of lxd as well as the snap. Doesn’t seem to make a difference.

For now the snap I’m building is configured with classic confinement.