Bug 441227 - Cannot find snap installed applications when using zsh as login shell
Summary: Cannot find snap installed applications when using zsh as login shell
Status: RESOLVED UPSTREAM
Alias: None
Product: kde
Classification: I don't know
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-20 10:11 UTC by Franco Pellegrini
Modified: 2021-10-21 15:07 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
insane data written? (28.63 KB, image/png)
2021-10-13 17:21 UTC, Franco Pellegrini
Details
/var/lib/snapd/desktop/applications content (46.89 KB, image/png)
2021-10-21 10:40 UTC, Franco Pellegrini
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Franco Pellegrini 2021-08-20 10:11:17 UTC
SUMMARY
Cannot find application installed via snap

STEPS TO REPRODUCE
1. install visual studio code via snap
2. install gimp via snap
3. press "super" or click on "application launcher"
4. Try to find them... they are not there

OBSERVED RESULT
There's no indexation of any snap installed program 


EXPECTED RESULT
find and launch snap applications

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-27-generic (64-bit)
Graphics Platform: X11
Processors: 6 × Intel® Core™ i5-8400 CPU @ 2.80GHz
Memory: 22.9 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630
Comment 1 Nate Graham 2021-08-20 15:06:15 UTC
Can you find them from KRunner? What about kmenuedit?
Comment 2 Franco Pellegrini 2021-08-20 16:04:31 UTC
No, I cannot find them anywhere, but I can run them via terminal just fine.
Tested on a fresh install KDE neon, and my workstation (old, but updated over time up today)
Comment 3 Nate Graham 2021-08-20 16:06:47 UTC
Did you install them using Discover, or another means?
Comment 4 Franco Pellegrini 2021-08-20 16:13:21 UTC
tried both ways, discover, and then via terminal. No success.
Comment 5 Nate Graham 2021-08-20 16:17:11 UTC
I don't know anything about snap packaging, but this seems like either a bug in Snap Packaging for not installing the necessary desktop integration bits, or a bug in our software for not looking for Snap apps in the places where they do get installed.

CCing the Neon packagers who are more familiar with Snap than I am.
Comment 6 David Edmundson 2021-10-05 22:39:15 UTC
>but I can run them via terminal just fine.

Please confirm desktop files can be found at $XDG_DATA_DIRS /applications
Comment 7 Franco Pellegrini 2021-10-06 10:08:02 UTC
(In reply to David Edmundson from comment #6)
> >but I can run them via terminal just fine.
> 
> Please confirm desktop files can be found at $XDG_DATA_DIRS /applications

it does not exists
Comment 8 Franco Pellegrini 2021-10-13 17:21:05 UTC
Created attachment 142399 [details]
insane data written?
Comment 9 Franco Pellegrini 2021-10-13 17:23:22 UTC
ups, I wrongly attached another image report to this thread. Sorry
Comment 10 David Edmundson 2021-10-14 12:23:58 UTC
>it does not exists

Then plasma is not at fault
Comment 11 Franco Pellegrini 2021-10-14 12:44:58 UTC
(In reply to David Edmundson from comment #10)
> >it does not exists
> 
> Then plasma is not at fault

but i'm using kde default program installer to add programs, it's KDE NEON fault?
Comment 12 Nate Graham 2021-10-14 14:24:45 UTC
Re-opening; this is bugs.kde.org, not bugs.plasmashell.org, and the issue could still be in a different part of our software stack.
Comment 13 Nate Graham 2021-10-14 14:25:58 UTC
Franco, how did you install the Snap app in question? Using Discover?

Can you try installing it on the command line to see if a relevant .desktop file appears in the applications folder of any of the directories in $XDG_DATA_DIRS?
Comment 14 Harald Sitter 2021-10-15 09:27:26 UTC
(snapd itself installs a file - /etc/profile.d/apps-bin-path.sh - that injects the relevant XDG_DATA_DIRS path, which is a non-standard location managed by snapd. if that is not working then chances are that file is broken/missing, or a garbage login shell is being used that doesn't source /etc/profile, or /etc/profile is broken, or something overwrites XDG_DATA_DIRS without appending the original entries)
Comment 15 Franco Pellegrini 2021-10-15 09:53:13 UTC
(In reply to Nate Graham from comment #13)
> Franco, how did you install the Snap app in question? Using Discover?
> 
> Can you try installing it on the command line to see if a relevant .desktop
> file appears in the applications folder of any of the directories in
> $XDG_DATA_DIRS?

I tried both ways, same results. For example installing gimp from command line or from discover. No icons, no folders. The only way to run it is via terminal typing "gimp"
Comment 16 Franco Pellegrini 2021-10-15 09:58:43 UTC
(In reply to Harald Sitter from comment #14)
> (snapd itself installs a file - /etc/profile.d/apps-bin-path.sh - that
> injects the relevant XDG_DATA_DIRS path, which is a non-standard location
> managed by snapd. if that is not working then chances are that file is
> broken/missing, or a garbage login shell is being used that doesn't source
> /etc/profile, or /etc/profile is broken, or something overwrites
> XDG_DATA_DIRS without appending the original entries)

If I type in a terminal
echo $XDG_DATA_DIRS 
I get:
/usr/share/plasma:/home/franco/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
Comment 17 Nate Graham 2021-10-15 15:59:12 UTC
(In reply to Franco Pellegrini from comment #15)

> I tried both ways, same results. For example installing gimp from command
> line or from discover. No icons, no folders. The only way to run it is via
> terminal typing "gimp"
Oh, sorry for leading you down the wrong path. I forgot that you were using Neon and that there wouldn't be anything there due to Neon's decision to remove AppStream Metadata from distro-provided apps end encourage people to use apps from Snap or Flatpak instead. So to a certain extent that's expected behavior; you should get GIMP from Snap or Flatpak.
Comment 18 Nate Graham 2021-10-15 16:00:34 UTC
(In reply to Franco Pellegrini from comment #16)
> If I type in a terminal
> echo $XDG_DATA_DIRS 
> I get:
> /usr/share/plasma:/home/franco/.local/share/flatpak/exports/share:/var/lib/
> flatpak/exports/share:/usr/local/share:/usr/share
Looks to me like the snap path isn't in there. Can you print the contents of /etc/profile.d/apps-bin-path.sh?
Comment 19 Franco Pellegrini 2021-10-18 10:18:21 UTC
(In reply to Nate Graham from comment #18)
> (In reply to Franco Pellegrini from comment #16)
> > If I type in a terminal
> > echo $XDG_DATA_DIRS 
> > I get:
> > /usr/share/plasma:/home/franco/.local/share/flatpak/exports/share:/var/lib/
> > flatpak/exports/share:/usr/local/share:/usr/share
> Looks to me like the snap path isn't in there. Can you print the contents of
> /etc/profile.d/apps-bin-path.sh?

# shellcheck shell=sh

# Expand $PATH to include the directory where snappy applications go.
snap_bin_path="/snap/bin"
if [ -n "${PATH##*${snap_bin_path}}" ] && [ -n "${PATH##*${snap_bin_path}:*}" ]; then
export PATH="$PATH:${snap_bin_path}"
fi

# Ensure base distro defaults xdg path are set if nothing filed up some
# defaults yet.
if [ -z "$XDG_DATA_DIRS" ]; then
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
fi

# Desktop files (used by desktop environments within both X11 and Wayland) are
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for
# snappy applications' desktop files.
snap_xdg_path="/var/lib/snapd/desktop"
if [ -n "${XDG_DATA_DIRS##*${snap_xdg_path}}" ] && [ -n "${XDG_DATA_DIRS##*${snap_xdg_path}:*}" ]; then
export XDG_DATA_DIRS="${XDG_DATA_DIRS}:${snap_xdg_path}"
fi
Comment 20 Franco Pellegrini 2021-10-18 10:20:24 UTC
Just as a comment, I did not edit such files, they are all untouched since I first installed KDE neon.
Comment 21 Franco Pellegrini 2021-10-19 11:44:53 UTC
I can reproduce this problem on my 3 different PC. All of them are updated, but from old KDE versions to the latest one. Its seems an old problem carried up today. What should I do to workaround the problem?
I test a NEW kde neon on a virtual machine, and the problem cannot be reproduced.
Comment 22 Nate Graham 2021-10-19 17:56:03 UTC
Do the expected .desktop files appear in /var/lib/snapd/desktop/?
Comment 23 Franco Pellegrini 2021-10-21 10:40:39 UTC
Created attachment 142717 [details]
/var/lib/snapd/desktop/applications content

(In reply to Nate Graham from comment #22)
> Do the expected .desktop files appear in /var/lib/snapd/desktop/?

yes, all snap app appears there as the attached screenshot (in my test example, code and gimp). But they does not appear as an installed app on KDE neon menu, or in KRunner (it only shows a folder named gimp)
Comment 24 Harald Sitter 2021-10-21 10:54:51 UTC
Are you using zsh there? If so it is configured as your login shell (in /etc/passwd)?
Comment 25 Franco Pellegrini 2021-10-21 14:05:00 UTC
(In reply to Harald Sitter from comment #24)
> Are you using zsh there? If so it is configured as your login shell (in
> /etc/passwd)?

I set zsh as the default shell using 
chsh -s "$(which zsh)"
Comment 27 Franco Pellegrini 2021-10-21 15:02:05 UTC
(In reply to Harald Sitter from comment #26)
> zsh counts as garbage login shell
> https://bugs.kde.org/show_bug.cgi?id=441227#c14
> 
> https://realjenius.com/2020/01/12/kde-neon-snap-apps-missing/

I can confirm that https://realjenius.com/2020/01/12/kde-neon-snap-apps-missing/ solves the issue