Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How to remove uninstalled snaps from cache?

Writer Matthew Martinez

When I install a snap with snap install <SNAPNAME> then it is being downloaded and mounted. When I remove it with snap remove <SNAPNAME> then 'everything' is being deleted like the snap, user settings dependecies and so on. But when I re-install the snap after removing it, it has no download time so the snap must be stored somewhere.

How can I clear the cache of snapd with all uninstalled snaps?

2

4 Answers

You can remove the files in /var/lib/snapd/cache without issue. Also there is no need to stop snapd before.

This was answered in Snapcraft forum:

The answers boil down to: you should not have a lot of files with hardlink count 1; at most 5 in the default install. If you have more than that, it’s a bug, please let us know.

And yes you can remove them without issue; no need to stop snapd.

Here the command to do that:

sudo sh -c 'rm -rf /var/lib/snapd/cache/*'
5

Also note that snap does not only keep removed snaps, but also up to 20 older versions of that snap (standard is 3 versions). So for me, cleaning up those remaining copies resulted in far more reclaimed storage than cleaning the cache (5GB vs 1GB). This website has a nice script which I used for that:

#!/bin/bash
#Removes old revisions of snaps
#CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision; do snap remove "$snapname" --revision="$revision" done

You can also simply do:

sudo snap remove --purge $PACKAGE
2

Or, you could always "sudo" the file manager, and go, graphically, into the folder, and remove them that way.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy