Snap doesn't create `.desktop` files for installed applications, nor add them to `$PATH`

I’ve installed

snap install --channel=latest/edge code-insiders --classic
snap install --channel=latest/edge firefox

…but neither were added to $PATH:

powershell-preview
PS /home/RokeJulianLockhart> pwsh-preview
pwsh-preview: The term 'pwsh-preview' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
powershell-preview
PS /home/RokeJulianLockhart> powershell-preview
powershell-preview: The term 'powershell-preview' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

…nor had .desktop files created for them:

Despite the presence of

Get-ChildItem -LiteralPath '/usr/share/applications' | Select-String 'firefox'

it outputs

PS /home/RokeJulianLockhart> Get-ChildItem -LiteralPath '/usr/share/applications' | Select-String 'firefox'

/usr/share/applications/gnome-mimeapps.list:16:application/rdf+xml=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:17:application/rss+xml=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:109:application/x-xpinstall=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:113:application/xhtml+xml=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:114:application/xml=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:197:image/gif=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:201:image/jpeg=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:208:image/png=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:266:text/html=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:276:text/xml=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:296:video/webm=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:325:x-scheme-handler/chrome=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:326:x-scheme-handler/ftp=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:329:x-scheme-handler/http=firefox_firefox.desktop
/usr/share/applications/gnome-mimeapps.list:330:x-scheme-handler/https=firefox_firefox.desktop

(which are perhaps remnants of an installation of https://software.opensuse.org/package/MozillaFirefox) as aforestated, KDE’s Application Launcher is unable to locate any, and certainly none exist for code-insiders:

Get-ChildItem -LiteralPath '/usr/share/applications' | Select-String 'visual studio'
PS /home/RokeJulianLockhart> Get-ChildItem -LiteralPath '/usr/share/applications' | Select-String 'visual studio'
Get-ChildItem -LiteralPath '/usr/share/applications' | Select-String 'insiders'
PS /home/RokeJulianLockhart> Get-ChildItem -LiteralPath '/usr/share/applications' | Select-String 'insiders'

Has anyone else experienced this?

Reported properly at https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/2037178.

It does via /etc/profile.d (just like flatpak) but if you’re using something other than bash, your shell might be not set up to read the directory out-of-the-box

It used to work on older installations, but doesn’t work now on any of my new openSUSE TW installations. I’ll reinstall Snap and try to verify.

If they are placed where you state, who would I report this to? The KDE Application Launcher Plasmoid maintainers, or openSUSE? By the way, flatpak works without issue, so I am not confident.

I would report that to the shell package in your distro (zsh/fish/whatever you use). Here’s what Arch does for zsh: https://gitlab.archlinux.org/archlinux/packaging/packages/zsh/-/blob/main/zprofile?ref_type=heads

The support for setting PATH from /etc/environment.d is a systemd feature, if it does not function properly (I.e. not adding /snap/bin to your path) you should file a bug in the respective distro against the systemd package…

Note though that environment changes only take effect after a reboot, so if you freshly installed snapd you will need to reboot once to make your system pick up the new path (I think all our install instructions say so, please point out if an official doc you followed did not)

1 Like

@ilya-fedi, I don’t think so, because I tested it with both PowerShell Core Preview and bash.

@ogra, I did reinitialize the computer, but it also states that if a new /etc/profile is sourced, reinitialization is unnecessary.

This only works in shell sessions… global environment changes require at least a re-login and for services even a reboot

1 Like