4

I run Kubuntu on a Makbook Air with a rather limited drive space. Snaps take just 2.8 GB but 1 is taken by two gnome packages. What are they even doing on Kubuntu?

snap list
Name                                  Version          Rev    Tracking         Publisher      Notes
bare                                  1.0              5      latest/stable    canonical✓     base
core18                                20221103         2632   latest/stable    canonical✓     base
core20                                20221027         1695   latest/stable    canonical✓     base
core22                                20220902         310    latest/stable    canonical✓     base
cups                                  2.4.2-4          836    latest/stable    openprinting✓  -
gnome-3-38-2004                       0+git.6f39565    119    latest/stable    canonical✓     -
gnome-42-2204                         0+git.c271a86    44     latest/stable    canonical✓     -
gtk-common-themes                     0.1-81-g442e511  1535   latest/stable/…  canonical✓     -
kde-frameworks-5-98-qt-5-15-6-core20  5.98.0           9      latest/stable    kde✓           -
kde-frameworks-5-core18               5.61.0           32     latest/stable    kde✓           -
onlyoffice-desktopeditors             7.2.1            133    latest/stable    onlyoffice✓    -
scantailor-advanced                   1.0.16           3      latest/stable    ppd            -
snapd                                 2.57.6           17883  latest/stable    canonical✓     snapd

ls -lh /var/lib/snapd/snaps/
total 2,8G
-rw------- 1 root root 4,0K avril 19  2022 bare_5.snap
-rw------- 1 root root  56M nov.   5 13:27 core18_2620.snap
-rw------- 1 root root  56M nov.  22 08:42 core18_2632.snap
-rw------- 1 root root  64M nov.   1 19:48 core20_1634.snap
-rw------- 1 root root  64M nov.   7 19:28 core20_1695.snap
-rw------- 2 root root  71M oct.   1 22:21 core22_275.snap
-rw------- 1 root root  73M oct.  21 21:42 core22_310.snap
-rw------- 2 root root  56M oct.   1 22:21 cups_803.snap
-rw------- 1 root root  56M oct.  22 21:56 cups_836.snap
-rw------- 2 root root 347M oct.  11 17:49 gnome-3-38-2004_119.snap
-rw------- 2 root root 447M nov.  25 17:26 gnome-42-2204_44.snap
-rw------- 1 root root  82M avril 19  2022 gtk-common-themes_1534.snap
-rw------- 1 root root  92M juil. 25 16:42 gtk-common-themes_1535.snap
-rw------- 2 root root 438M nov.  24 09:20 kde-frameworks-5-98-qt-5-15-6-core20_9.snap
-rw------- 2 root root 261M oct.   5 21:57 kde-frameworks-5-core18_32.snap
-rw------- 2 root root 607M nov.  25 14:14 onlyoffice-desktopeditors_133.snap
drwxr-xr-x 2 root root 4,0K avril  8  2022 partial
-rw------- 2 root root 3,2M oct.   5 21:57 scantailor-advanced_3.snap
-rw------- 1 root root  50M nov.  29 09:55 snapd_17883.snap

Here it says that unlisted items (after that command) can be safely removed, but that the listed ones are mandatory. But I'm not sure if that's true or that I understand it correctly.

Maybe gnome snaps are needed to install other gtk snaps, while kde-frameworks are needed to install kde snaps. Is that so?

cipricus
  • 3,444
  • 2
  • 34
  • 85

1 Answers1

5

Like deb-packages, snaps may have depenencies (other snaps) which are pulled in when you install a snap.

You can find out which dependencies a snap has by looking into the snap's .yaml-file which is located at /snap/<snapname>/<revision-number>/meta/snap.yaml, the keywords base and default-provider are the important part.

The answer you linked just sums up the information of the .yaml-files from all installed snaps, so all snaps which are dependencies of other snaps will be listed. Thus, a snap not listed is not a dependency and can be removed.

Since snapd doesnt provide an autoremove-mechanism like apt, dependencies of a snap will never get removed when you remove a snap unless you do it manually.

Since you say your disk space is rather limited, you should also clean up the cache with

sudo bash -c 'rm /var/lib/snapd/cache/*' 
mook765
  • 15,925
  • 1
    I am curious: whats the point of sudo bash -c 'rm... instead of sudo rm ...? – guntbert Dec 25 '22 at 17:39
  • 2
    @guntbert The directory /var/lib/snapd/cache/ is only accessable by the user root, see ls -ld /var/lib/snapd/cache/. Due to this fact globbing will not work in sudo rm /var/lib/snapd/cache/* because the globbing is done by the shell which still acts with normal user privileges. So we have to run the command in a subshell which has root-privileges like in sudo bash -c 'rm /var/lib/snapd/cache/*' for globbing to work correctly. – mook765 Dec 25 '22 at 18:01
  • Ah, I see ... you are right of course :-) (I didn't bother globbing and removed the entire cache directory, assuming it will be recreated if necessary) – guntbert Dec 25 '22 at 18:06