flatpak / flatpak

Linux application sandboxing and distribution framework
https://flatpak.org
GNU Lesser General Public License v2.1
4.24k stars 406 forks source link

[Bug]: No desktop entries for Flatpaks apps #5732

Open Ombrelin opened 7 months ago

Ombrelin commented 7 months ago

Checklist

Flatpak version

1.14.2

What Linux distribution are you using?

Ubuntu

Linux distribution version

22.04LTS

What architecture are you using?

x86_64

How to reproduce

Install Flatpak apps

Expected Behavior

Having desktop entries for the installed flatpak apps

Actual Behavior

No desktop entries for the installed flatpak apps

Additional Information

  1. I've tried the recommended fixes : logout/login, gnome session reset, reboot ...
  2. This is a computer to which I access exclusively via Remote Desktop (xRDP)
chrisawi commented 7 months ago

This is a computer to which I access exclusively via Remote Desktop (xRDP)

This seems like the key detail. Flatpak wants XDG_DATA_DIRS to include its export dirs (e.g. /var/lib/flatpak/exports/share). It attempts to set this various ways, but I suspect that none of them are working for your setup. It ships systemd environment generators, as well as a profile drop-in (/etc/profile.d/flatpak.sh) and the equivalent for fish.

Is XDG_DATA_DIRS set correctly? It's specifically the environment of the gnome-shell process that matters:

cat /proc/$(pidof gnome-shell)/environ | tr '\0' '\n' | grep XDG_DATA_DIRS

If pidof gnome-shell doesn't work correctly, you can manually replace that with the PID of gnome-shell.

Ombrelin commented 7 months ago

Hi, thanks for you quick answer ! So pidof gnome-shell return two pids, I ran the command for both :

$ cat /proc/4136/environ | tr '\0' '\n' | grep XDG_DATA_DIRS
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/
$ sudo cat /proc/1839/environ | tr '\0' '\n' | grep XDG_DATA_DIRS
XDG_DATA_DIRS=/usr/share/gdm/greeter:/usr/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/

The second one (which required sudo to cat) has the flatpak exports, but not the first one

chrisawi commented 7 months ago

XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/

That's what I expected to see. I don't really know anything about xrdp, but I do see that /etc/xrdp/startwm.sh sources /etc/profile, which seems like it should be enough to get that variable set correctly.

You could check echo $XDG_DATA_DIRS in a terminal and then again after creating a login shell with bash -l. If the new shell has flatpak's export directories, then the profile drop-in is doing its job.

I don't know if the way you're using xrdp involves that script, but unless that bash -l test fails, I don't think this is a flatpak bug. Any environment needs to either (or both):

Ombrelin commented 7 months ago
$ echo $XDG_DATA_DIRS
/usr/share/gnome:/usr/local/share/:/usr/share/
$ bash -l
$ echo $XDG_DATA_DIRS 
/home/<my username>/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/home/<my username>/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop

Something which I can add though is that I don't use bash as login shell (I use powershell), but I do the same on another machine and have no issue with Flatpaks desktop entries so I don't think it's related (I access that other machine physically though).

chrisawi commented 7 months ago

I wonder how the flatpak exports got added twice there. The profile drop-in is meant to be idempotent.

I don't use bash as login shell (I use powershell)

Using a non-posix shell as your login shell is a bit perilous. Flatpak doesn't ship a profile drop-in for powershell (assuming such a mechanism exists). I expect a PR adding one would be accepted though.

I would consider keeping bash as the login shell and configuring your terminal to launch powershell as a custom command.

(I access that other machine physically though).

GDM imports the environment of the systemd user manager, so that's probably how it's working.

Ombrelin commented 7 months ago

I wonder how the flatpak exports got added twice there. The profile drop-in is meant to be idempotent.

I'm not sure either, you think this could be related to my problem ? If no, do you have any other lead to identify the source of this problem, or do you think this is rather a xRDP issue rather than flatpak ?

chrisawi commented 7 months ago

I don't think it's directly related.

The only action flatpak could take would be to add support for setting XDG_DATA_DIRS for powershell, as it already does for sh, csh, and fish. If you can confirm that powershell provides a vendor drop-in directory for that, we could convert this to an enhancement request. Of course, that only helps flatpak; you can see that snapd for example has the same problem.

In the interest of practicality, I still think your best option is to not set powershell as your login shell.

or do you think this is rather a xRDP issue rather than flatpak ?

xrdp could resolve this by importing systemd's environment like GDM does, but it's not necessarily a bug that they don't.

Ombrelin commented 7 months ago

Okay, is there any manual action which I could do to solve my problem, like copying over desktop entries so that my flatpak apps appear in the desktop ?

chrisawi commented 7 months ago

Presumably you could set XDG_DATA_DIRS in whatever the equivalent of a profile script is for powershell.

It needs to include ~/.local/share/flatpak/exports/share and /var/lib/flatpak/exports/share in addition to the default directories.