Remove old versions of snaps

Using Ubuntu 24.04 (default - minimal - installation)

Firefox snap is all over my system. And now it is causing me trouble. I need to get rid of it -but I can’t. I’ve tried, of course the basic:

sudo snap remove firefox

I’ve tried to use the scripts kindly offered on this site and a similar script here. And they do remove a thing or two, but they both meet an unpassable barrier and get no further, leaving most of the “old snap versions” untouched

The barrier (error) “cannot perform the following tasks”:

  • Remove data for snap “firefox” (4793) (unlinkat /var/snap/firefox/common/host-hunspell/es_CU.dic: read-only file system)

Should I try to manually remove the offending file (seems to be a Spanish dictionary) If so how? (the “read-only file system” seems a bit daunting)

Grateful for any wise suggestions

I have the same snap installed but only have the en_US.aff and en_US.dic files in that directory. They are owned by root:root with 644 permissions.

If you want to completely uninstall the Firefox snap, I don’t think it could hurt to manually remove that file. You’d probably have to use sudo permissions to it.

Afraid that doesn’t work. I am not “owner” of the files - (system) and cannot change the permissions of these files, far less delete them.

There are 52 files in the offending folder (/var/snap/firefox/common/host-hunspell) all with extension dic or aff; and all but 12 actually have rwx permissions for owner (root) and group (root), I suspect these dictionary files are used not so much by Firefox as by Thunderbird, where I use spellcheck.

What matters for me is not to get rid of the folder, but to remove old versions of snaps. The error message I referred to as “the barrier” interrupts the script.

I think the word “unlinkat” in that message is the clue.
All but 12 of the files look like this.

There are a lot of man pages and whatnot about “unlinkat”. But they are a bit above me. Is there any simple solution?

1 Like

It looks like those are links to a file somewhere else. In any case you should be able to remove using sudo. I don’t know if that would affect Thunderbird. I would think not, especially using snaps. I kind of thought one of the primary benefits of using snaps/flatpak/appimage was that they contained all the requirements to run. Kind of self contained.

To be safe have a snapshot or backup before removing for sure.

Here is the snap clean script I use.

$ cat snap-clean.sh 
#!/bin/bash
# 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
2 Likes

Can i ask

Why remove snaps ?
Does it cause problems ?
Space allocation is almost nothing …
Or have i missed something

2 Likes