Old Ubuntu core snap versions are filling up disk space

Right now I don't believe it's possible to change the number of old versions of any snap, that's set at 3. If you see more than that, it's likely a bug, so should be filed at https://bugs.launchpad.net/ubuntu/+source/snapd


This post lists several solutions for older snap version removing:

Manual script by popey to delete "all old versions of snaps"

#!/bin/bash
# https://superuser.com/a/1330590
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS set -eu

snap list --all | awk '/disabled/{print $1, $3}' |
    while read snapname revision; do
        snap remove "$snapname" --revision="$revision"
    done

And "snap set system refresh.retain" setting for "snap 2.34 and later" by Mustapha Hadid to store only 2 revisions of every snap:

$ sudo snap set system refresh.retain=2 

The refresh.retain value can only be a number between 2 and 20 and has a default value of 3