Flatpak trouble

I have installed flatpak on my machine, but cannot install any flatpak, because I keep getting the same errors over and over again, no matter which flatpak I try to install:

flatpak install flathub org.tabos.roger

Note that the directories 

'/var/lib/flatpak/exports/share'
'/home/falter/.local/share/flatpak/exports/share'

are not in the search path set by the XDG_DATA_DIRS environment variable, so
applications installed by Flatpak may not appear on your desktop until the
session is restarted.

Looking for matches…
Fehler: No remote refs found similar to ‘flathub’

I need a flatpak which otherwise is not available as a normal application or snap. I'd be grateful if someone could explain what is going wrong here and how to (hopefully) fix it.

Hmm, that does not necessarily mean the flatpaks aren't installed
It's just that i.e Ubuntu flatpaks expect a different desktop path.

Have you tried starting with i.e 'flatpak run org.tabos.roger' ?

If I do this, nothing happens, and

flatpak list

yields no results, so nothing is installed. There actually are two errors in the message, it seems: the second one seems to say that Flathub as a source is not recognized, if I get it right.

That means that Flatpaks might not appear in the menu system, I think.
The reason your flatpaks aren't installing is here:

You need to install the flathub repository.

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
2 Likes

Thanks so much! This is the solution to all the trouble. I have tacitly assumed that if you install flatpak on your system, you are already good to go. You never stop learning...

I managed to install my flatpak, and also the errors about directories not being in XDG_DATA_DIRS have disappeared!

Edit: This is not true. The errors are still there, but it does not really matter, since the flatpaks are installed and work. On installation, though, I am not offered the choice of user/system install. They all are in /var now, so I guess it is a system install.

I tried to follow advice from various sources to fix the XDG_DATA_DIRS thing like putting "export ..." into .bashrc or .profile, but this did not solve the issue. Maybe someone here knows more about this.

.zshrc or .zprofile :-​)

I have switched back to bash - old habit...

You need to reload the terminal (exec bash) with the export ... added before you install the flatpak

I do not know if I get you right here: do you mean

source .bashrc

or something else?

source .bashrc is a terrible idea and might cause memory leaks, etc because it doesn't actually clear local variables and such. It just reloads the .bashrc.

exec bash re-runs the entire shell (and is better than just plain bash because it loads in the current shell so you don't need to type exit twice)

Thank you, I think I will leave this as it is. Maybe this whole thing is just a permission problem. At any rate the flatpaks install and run allright.
There is another strange behaviour related to installations which I have observed: it seems that somehow I am always some kind of superuser. When I do 'api APPLICATION' (or its extended version 'sudo apt-get install ...) in Terminal, I am never asked for a password.
If I do 'sudo apt install APPLICATION', however, I am asked for a password. Is there an explanation for this?
Sorry, I am drifting off a bit...

Yes, this is the 7th post since marking the topic as "solved".
Please start another thread if there are more problems.