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!