Accessing /tmp from snaps?

I often use /tmp to save files I don’t need to keep or to transfer them between applications.

But it seems with snaps this doesn’t work, is there any way to access /tmp?
File dialogs show the contents of /tmp from such applications but I can’t seem to read or write any files in them.

I’m asking this both as a snap developer (where I might create a file in /tmp from a snap to be opened by applications outside the snap) and as a user (where I might create a file in /tmp and want to open it from a snap).

snaps use a per-app /tmp, there is no way to access the hosts /tmp directory easily to prevent snaps from stealing data of other running applications …

but what if an app needs to open a temporaty file with another app?

Then it should put temporary files somewhere else than /tmp . For example firefox uses ~/Downloads which may not be a perfect choice but shows the way.

Quick clarification: this is correct inasmuch as it relates to accessing the system’s /tmp and sharing access to the same space between snaps, but the /tmp that a given snap application can see is specific to the given snap, not the application. This is an important distinction, as snaps can include multiple applications. If each of those applications saw a different /tmp, they wouldn’t be able to share things between them. Thankfully that’s not the case-- every app within the same snap sees the same /tmp, so it’s possible to e.g. proxy to the PHP app’s unix socket in /tmp/sockets from the Apache app.

1 Like

What is the best chance then ?

Just a 0,02€ bet

sudo   mount   --bind   /something   /home/user/snap/somewhere

Roughly as in GiMP and thumbnails for .xcf files

?

You may set TMPDIR variable to redirect saving of files from /tmp to somewhere else. Not all apps respect it but most do.