31

I'm currently using a Ubuntu 20.04 machine with a small root volume. The default snap setup occupies ~1G space, though with only a few packages. And when I tried to remove core from snap I got the following error.

# snap remove core18
error: cannot remove "core18": snap "core18" is not removable: snap is being used by snaps gnome-3-34-1804, gtk-common-themes and snap-store.

I understand I can work around the issue by manually remove the dependants first, but is there a one-liner solution that manages the dependencies automatically so that all snaps and snapd can be removed in one go?

wlnirvana
  • 604
  • So the design philosophy of snap is to make every package as independent and self-contained as possible? Interesting. But what about stuff like core18 and snap-store? Are they somewhat base/root package needed by all other packages? – wlnirvana Jan 19 '21 at 03:22
  • That all starts to make sense now. But just one last question, is there an official command to automatically remove all snap installed packages and snapd as well? I happen to have a small root volume and want to safely clear up /var/lib/snapd directory. – wlnirvana Jan 19 '21 at 05:27
  • @user535733 You are right. Question edited. – wlnirvana Jan 19 '21 at 06:21
  • 1
  • @vanadium That answer fails at the first line of snap list's output, which is actually a header line rather than packages. This is easy to fix, though. But what is hard is the dependencies (though there is very few) requires packages to be removed in a specific order, which that answer fails to address as well. – wlnirvana Jan 19 '21 at 08:21
  • @OrganicMarble Yes. Perfect. (Though I did read answers before posting this question, because I see different suggestions on whether to manually remove or not snaps before deleting snapd with apt. I double checked the deb packaging script this time, and I believe the answer you linked will work. – wlnirvana Jan 21 '21 at 00:06
  • @wlnirvana glad it helped. I greatly dislike snaps and the instructions linked in one of the answers to that questions are now my standard method for ditching them. https://www.kevin-custer.com/blog/disabling-snaps-in-ubuntu-20-04/ – Organic Marble Jan 21 '21 at 00:26

2 Answers2

28

A one-liner this is not but, if you would like to completely remove everything related to snaps on your machine, follow these steps:

  1. Open the Terminal

  2. List all the snaps installed on your system with snap list. You will see something like this:

    Name                  Version                     Rev    Tracking         Publisher         Notes
    chromium              87.0.4280.141               1444   latest/stable    canonical✓        -
    core                  16-2.48.2                   10583  latest/stable    canonical✓        core
    core18                20201210                    1944   latest/stable    canonical✓        base
    emote                 1.3.0                       12     latest/stable    tom-james-watson  -
    gnome-3-28-1804       3.28.0-19-g98f9e67.98f9e67  145    latest/stable    canonical✓        -
    gnome-3-34-1804       0+git.3556cb3               66     latest/stable    canonical✓        -
    gnome-system-monitor  3.36.0-12-g35f88a56d7       148    latest/stable/…  canonical✓        -
    gtk-common-themes     0.1-50-gf7627e4             1514   latest/stable/…  canonical✓        -
    snap-store            3.38.0-59-g494f078          518    latest/stable/…  canonical✓        -
    spotify               1.1.46.916.g416cacf1        43     latest/stable    spotify✓          -
    vlc                   3.0.11                      1700   latest/stable    videolan✓         -
    
  3. Remove each snap that you may have chosen to install using sudo snap remove <package>:

    sudo snap remove chromium
    sudo snap remove emote
    sudo snap remove spotify
    sudo snap remove vlc
    
  4. Remove the core snaps in this order (your list may be slightly different):

    sudo snap remove snap-store
    sudo snap remove gtk-common-themes
    sudo snap remove gnome-system-monitor
    sudo snap remove gnome-3-34-1804
    sudo snap remove gnome-3-28-1804
    sudo snap remove core18
    sudo snap remove snapd
    
  5. Verify there are no more snaps installed with snap list. You should see a message like this:

    No snaps are installed yet. Try 'snap install hello-world'.
    
  6. Unmount the snap mount points with sudo umount /snap/core/{point}, replacing {point} with the actual mount point. You can find the complete list using df -h.

    Note: In Ubuntu 20.10 (and newer) you only need to do this: sudo umount /var/snap.

  7. Remove snapd from your system with sudo apt purge snapd

  8. Remove any snap-related directories that might remain:

    rm -rf ~/snap
    sudo rm -rf /snap
    sudo rm -rf /var/snap
    sudo rm -rf /var/lib/snapd
    

Your system will now be devoid of snaps.

14

You can run:

sudo snap remove $(snap list | awk '!/^Name|^core/ {print $1}')
sudo apt remove --purge -y snapd gnome-software-plugin-snap

Or in one line:

sudo snap remove $(snap list | awk '!/^Name|^core/ {print $1}') && sudo apt remove --purge -y snapd gnome-software-plugin-snap

I should add that removing snapd and gnome-software-plugin-snap1 remove also ubuntu-software, the Ubuntu software store. This can be fixed by running

sudo apt install gnome-software

however the icons do not all come back...

Rishon_JR
  • 1,013
Charles Green
  • 21,339