#931776 snapd: Installed snaps do not appear in desktop launcher in Debian buster.

Package:
snapd
Source:
snapd
Description:
Daemon and tooling that enable snap packages
Submitter:
Ruben Vorderman
Date:
2024-08-09 13:21:05 UTC
Severity:
important
#931776#5
Date:
2019-07-10 10:21:53 UTC
From:
To:
Dear Maintainer,

I have installed the following snaps on my system:

Name                     Version                 Rev   Tracking  Publisher
Notes
atom                     1.38.2                  232   stable    snapcrafters
classic
core                     16-2.39.3               7270  stable    canonical✓
core
intellij-idea-community  2019.1.3                152   stable    jetbrains✓
classic
pycharm-community        2019.1.3                132   stable    jetbrains✓
classic

In Debian stretch these applications could be launched from the mate-brisk-
menu. In Debian buster this is no longer possible.
I checked a few things:

On an interactive shell:
$ echo $XDG_DATA_DIRS
/usr/share/mate:/home/ruben/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

On a login shell:
$ bash --login
$ echo $XDG_DATA_DIRS
/usr/share/mate:/home/ruben/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin

Apparently /etc/profile works as it should. But for some reason I cannot launch
snaps from my launcher (the mate-brisk-menu).
This *might* be a bug in the mate-brisk-menu, but I don't think so as it still
finds flatpaks.

I did a clean install of Debian buster on another machine and tried it with a
user that started with an empty home directory. This had the same result.

This bug is related (loosely) to #906680. In conjunction they make it non-
trivial to start snaps which is rather annoying.

If there are additional steps that need to be taken to identify the cause of
this bug I am happy to do so. I hope the provided information helps.

Best regards,
Ruben Vorderman





*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
   * What was the outcome of this action?
   * What outcome did you expect instead?

*** End of the template - remove these template lines ***

#931776#10
Date:
2019-07-12 05:37:29 UTC
From:
To:
Dear maintainer,

I did some fiddling around. It appears that the .destkop files that are
created work fine in other directories that are in $XDG_DATA_DIRS.

As a workaround I use

     sudo ln -s /var/lib/snapd/desktop/applications
/usr/share/applications/snapd

This works (sometimes logging out and in again is required).

I think the issue is caused by the apparmor configuration. The menu
generating process may not be allowed to access /var/lib/snapd/desktop.
I do not have enough experience with apparmor to fully debug that. I
tried looking in the apparmor config files, but could not find the cause
of the issue.

Best regards,

Ruben Vorderman

#931776#15
Date:
2020-05-17 11:51:18 UTC
From:
To:
Hi,

So, snapd sets $PATH and $XDG_DATA_DIRS in /etc/profile.d/apps-bin-path.sh, but /etc/profile
and /etc/profile.d aren't used in the graphical logins in Debian. [1]

Older versions of snapd also had set $XDG_DATA_DIRS in /etc/X11/Xsession.d/65snappy, which
was used in the X sessions. But that was dropped upstream in [2], which happened some time
after Stretch was released, but before Buster was released.

I guess this is the cause of the problem...


[1] https://wiki.debian.org/EnvironmentVariables
[2] https://github.com/snapcore/snapd/pull/3398

#931776#20
Date:
2022-04-21 21:30:36 UTC
From:
To:
Dear Maintainer

Debian 11 with snapd 2.49-1 still struggles with the same problem.

Quick check in terminal shows XDG_DATA_DIRS variable lacking
/var/lib/snapd/desktop
However, after the "exec bash --login" variable looks good.
After switching from default lightdm to gdm3 all just works.

Best regards

technical details, comparing "set" before and after "exec bash --login"

filip@filip:~$ diff -u bez z
--- bez 2022-04-21 23:11:44.699961183 +0200
+++ z 2022-04-21 23:11:50.747977323 +0200
@@ -1,5 +1,5 @@
 BASH=/usr/bin/bash
-BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:globasciiranges:histappend:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
+BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:globasciiranges:histappend:hostcomplete:interactive_comments:login_shell:progcomp:promptvars:sourcepath
 BASH_ALIASES=()
 BASH_ARGC=([0]="0")
 BASH_ARGV=()
@@ -40,9 +40,10 @@
 OPTERR=1
 OPTIND=1
 OSTYPE=linux-gnu
-PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
+PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
 PIPESTATUS=([0]="0")
 PPID=49715
+PROMPT_COMMAND=__vte_prompt_command
 PS1='\[\e]0;\u@\h:
\w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
'
 PS2='> '
 PS4='+ '
@@ -61,10 +62,10 @@
 UID=1000
 USER=filip
 VTE_VERSION=6203
-WINDOWID=6291462
+WINDOWID=6292272
 XAUTHORITY=/home/filip/.Xauthority
 XDG_CURRENT_DESKTOP=MATE
-XDG_DATA_DIRS=/usr/share/mate:/usr/local/share/:/usr/share/
+XDG_DATA_DIRS=/usr/share/mate:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
 XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/filip
 XDG_RUNTIME_DIR=/run/user/1000
 XDG_SEAT=seat0
@@ -77,3 +78,17 @@
 XDG_VTNR=7
 XMODIFIERS=@im=ibus
 _=set
+snap_bin_path=/snap/bin
+snap_xdg_path=/var/lib/snapd/desktop
+__vte_osc7 ()
+{
+    printf "\033]7;file://%s%s\033\\" "${HOSTNAME}"
"$(/usr/libexec/vte-urlencode-cwd)"
+}
+__vte_prompt_command ()
+{
+    local pwd='~';
+    [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/};
+    pwd="${pwd//[[:cntrl:]]}";
+    printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${pwd}";
+    __vte_osc7
+}

#931776#25
Date:
2024-08-09 13:18:13 UTC
From:
To:
Dear Maintainer,

while the bug is still present in Debian trixie, it can be fixed by linking (or copying) the file:

/etc/profile.d/apps-bin-path.sh

to

/etc/X11/Xsession.d/20snapd

PS: This is actually a method that flatpak package uses to make the flatpak-installed applications available in the graphical environment (having file /etc/X11/Xsession.d/20flatpak identical to /etc/profile.d/flatpak.sh).

Best regards, Pavel Reznicek