I am looking for a way to remove snap packages that are no longer depended upon, similar to apt autopurge
/apt autoremove
for .deb
/dpkg packages.
What does apt autoremove do?
It removes packages that were installed as dependencies, recommendations, or suggestions of other packages, but are no longer marked as such after an update, or because the original package has since been uninstalled.
But snap packages are dependencyless
Contrary to this common misconception, anyone who installs a common snap (eg. snap install firefox
), will see that several other snaps are installed as its dependency, such as gtk-common-themes
, gnome-<version>
, core<version>
, and others that are in turn dependencies of these.
So, this question has been incorrectly marked as a duplicate.
Just remove the snap
The question is not how to remove a snap, but how to remove all automatically installed ones that are no longer needed. Finding out which snaps are no longer depended on is non-trivial when there are hundreds of them installed.
apt autopurge
removes packages that are no longer needed. I'm looking for the snap equivalent to that... removing snaps that were installed as dependencies but aren't needed anymore, eg. the depending snap was uninstalled, updated, etc. – P Varga May 15 '22 at 04:13snap install firefox
and it will also installgtk-common-themes
,gnome-3-38-2004
or similar,core20
orcore18
, andbare
. So the question stands – P Varga May 16 '22 at 01:44/snap/firefox/current/snap/snapcraft.yaml
for firefox; but they're not dependencies (but plugs). The base is different; snap packages built for Ubuntu Core 16 will requirecore16
.. but that's still an important plug called base. – guiverc May 16 '22 at 01:56core
for example that no other snap needs any more, because it moved tocore18
, thencore20
, etc etc. Socore16
will still be installed but unnecessarily. So the question is, how to remove these stale packages that are left behind? – P Varga May 16 '22 at 02:04snap list --all | awk '$6~"disabled"{print $1" --revision "$3}' | xargs -rn3 sudo snap remove
– Pablo Bianchi May 26 '22 at 04:52gnome-3-38-2004
– P Varga May 28 '22 at 23:35