Filesystem location for file that flatpak is allowed to read

I have this problem where I want this environment variable to work inside the flatpak package. The variable is set in the bashrc file. Also, the variable works when I run my app before packaging. After packaging the variable stops working. The var is named GOOGLE_APPLICATION_CREDENTIALS. My package builds well, thanks to people on this forum and others. Now to launch the program I need to launch it from the terminal. If I launch from a runlauncher, like krunner, the variable is not loaded.

I used flatseal and set the env var and my app works. This is great. Now I want to place a file somewhere on the host sytem that’s accessable to the flatpak package regardless of whether or not it’s installed in user or non-user mode. I want to use the ‘–env’ finishing option in my flatpak manifest yaml file.

I’m looking at this page:

The file I want on the system will hopefully actually be a link to the file I have in my home folder. I’m hoping a symbolic link will work. Then, installing on a new system, the real location can be used or the symbolic link can be used again. Additionally the flatpak can be installed user or non-user.

TLDR: Where do I put things on the system that I can read from my flatpak that are not in the home directory? (and are not temporary) ??


All flatpaks, whether installed per-user or otherwise, have write access to $HOME/.var/app/$APP_ID, and the data subdirectory of this is used for persistent app data:

$ flatpak run --command=bash org.gnome.clocks -c "echo \$XDG_DATA_HOME"
1 Like

this is definitely a start. the output of your bash command should not start with ‘var’, right? Thanks for your answer! can you use $ in the --env option in the finishing arguments section of the yaml manifest?

On Fedora Silverblue /home is a symlink to /var/home.

As for using $HOME in --env, I don’t know, sorry.

And this caused me a lot of problem because app saved path as /home/* but the permissions didn’t allow for it, so I got a lot of flatpak apps telling me they couldn’t open the files anymore.

(I moved from plain Fedora to SilverBlue and in the greatest tradition I just restored m home directory)