Is there an equivalent snap command that does for Snaps what apt-get autoremove / apt-get autopurge does for Apt packages? (Also available as apt autoremove...)
Update 3: For the curious and those who end up here from Google, the equivalent command for FlatPak is flatpak uninstall --unused.
Update: I wanted to clarify the question after receiving an answer which states:
Snaps do not have dependencies like apt, so an equivalent to autoremove seems unnecessary.
This is incorrect. Consider the following (just one example of many):
$ snap list
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
core 16-2.57.6 14399 latest/stable canonical✓ core
core18 20221212 2667 latest/stable canonical✓ base
core20 20221123 1738 latest/stable canonical✓ base
$ sudo snap install nvim --classic
nvim v0.8.1 from neovim-snap (neovim-snap) installed
$ snap list
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
core 16-2.57.6 14399 latest/stable canonical✓ core
core18 20221212 2667 latest/stable canonical✓ base
core20 20221123 1738 latest/stable canonical✓ base
core22 20221129 444 latest/stable canonical✓ base
nvim v0.8.1 2775 latest/stable neovim-snap classic
$ sudo snap remove nvim
nvim removed
$ snap list
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
core 16-2.57.6 14399 latest/stable canonical✓ core
core18 20221212 2667 latest/stable canonical✓ base
core20 20221123 1738 latest/stable canonical✓ base
core22 20221129 444 latest/stable canonical✓ base
$
Before installing nvim, core22 was not installed. After removing it, core22 is left behind even though nothing depends on it now.
Update 2:
In the above example, the installed dependency core22 is a base snap. Here's another example which demonstrates that the same issue is also present for non-base dependencies:
$ sudo snap list
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
core 16-2.57.6 14399 latest/stable canonical✓ core
core18 20221212 2667 latest/stable canonical✓ base
core20 20221123 1738 latest/stable canonical✓ base
core22 20221129 444 latest/stable canonical✓ base
$ sudo snap install falkon
falkon 22.08.2 from KDE✓ installed
$ snap list
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
core 16-2.57.6 14399 latest/stable canonical✓ core
core18 20221212 2667 latest/stable canonical✓ base
core20 20221123 1738 latest/stable canonical✓ base
core22 20221129 444 latest/stable canonical✓ base
falkon 22.08.2 86 latest/stable kde✓ -
kde-frameworks-5-98-qt-5-15-6-core20 5.98.0 9 latest/stable kde✓ -
$ sudo snap remove falkon
falkon removed
$ snap list
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
core 16-2.57.6 14399 latest/stable canonical✓ core
core18 20221212 2667 latest/stable canonical✓ base
core20 20221123 1738 latest/stable canonical✓ base
core22 20221129 444 latest/stable canonical✓ base
kde-frameworks-5-98-qt-5-15-6-core20 5.98.0 9 latest/stable kde✓ -
$
After installing and then removing the falkon snap, the unused dependency kde-frameworks-5-... is left behind.
nvimneeds it, it's a "dependency". Yes it's also a base snap. And I am looking for anapt auroremoveanalog exactly because it did not remove when I removednvim. – P Varga Dec 21 '22 at 08:46.debpackages like non-Core versions of Ubuntu. – Terrance Dec 21 '22 at 14:37nvimandcore22showed a "base snap" being installed. Now I've added another example withfalkonwhich shows the same happens for a non-base dependency – P Varga Dec 21 '22 at 18:18apt-markfor example is a separate command fromapt-get). But looks like that's not the case – P Varga Dec 21 '22 at 21:13apt-get autopurgefor Snap. – P Varga Jan 24 '23 at 23:19