3

UPDATE: No, it is not safe to delete these snaps. I deleted them and can no longer open three of my applications. Attempt at opening Visual Studio Code:

~$ code internal error, please report: running "code" failed: cannot find installed snap "code" at revision 33: missing file /snap/code/33/meta/snap.yaml

The snaps in /var/lib/snapd/snaps are taking up 2.0 GB of space on my disk right now. I want to clear up space, but I'm not sure if deleting these snaps is safe (if so, can I just run sudo rm -rf *?)

This is what I see when I run snap list:

code_32.snap              gnome-3-28-1804_116.snap   gnome-logs_93.snap
code_33.snap              gnome-3-34-1804_27.snap    gnome-system-monitor_135.snap
core18_1705.snap          gnome-3-34-1804_33.snap    gnome-system-monitor_145.snap
core18_1754.snap          gnome-calculator_730.snap  gtk-common-themes_1502.snap
core_8935.snap            gnome-calculator_748.snap  gtk-common-themes_1506.snap
core_9066.snap            gnome-characters_495.snap  partial
discord_109.snap          gnome-characters_539.snap  spotify_36.snap
gnome-3-28-1804_110.snap  gnome-logs_100.snap        spotify_41.snap

What are the gnome, code, and core snaps?

I've installed discord and spotify. Will deleting the discord and spotify snaps lead to any issues with opening those applications?

I'm using Ubuntu 18.04.3 LTS.

8
  • What, did you delete the core snaps too? Probably a good idea to just purge and reinstall snapd at this point. For future reference you can search for packages and discover what they are on the snapcraft site: snapcraft.io
    – GammaGames
    Jun 4 '20 at 20:26
  • As for how to reinstall: superuser.com/a/102465/920594
    – GammaGames
    Jun 4 '20 at 20:28
  • Yes I did delete the core snaps too. I'm a fking idiot, right? So snaps... are.. what, application software? I'm confused. Are you saying that if I purge and reinstall snapd I will be able to open Discord, Spotify, and VSCode again with all my extensions and settings retained?
    – silkthyme
    Jun 4 '20 at 20:48
  • Maybe the problem was I navigated to the snaps directory and used sudo rm -rf to manually delete each snap, instead of deleting with sudo apt purge snapd. The reason I didn't use that command is because I wasn't sure if it was safe to delete the whole snaps directory. Are you absolutely sure purging and reinstalling snapd is safe?
    – silkthyme
    Jun 4 '20 at 20:53
  • Snaps are just a way to package software, core is the "core" stuff that snapd needs in order to function. Removing files manually is dangerous and can lead to you hosing your system pretty easily, almost everyone has made this mistake at least once so no worries ;) sudo apt purge snapd will remove the package and all config files. I'm not 100% certain if it'll be completely successful, but I would definitely try that first.
    – GammaGames
    Jun 4 '20 at 21:05
1

So, there's a couple questions here and I'll try to address them in an order that makes sense:

  1. What are snaps?

Snaps are a way to package software, like deb packages or flatpaks. They work across linux distros and have become popular because of how easy they are to maintain and use. You can find more here: https://snapcraft.io/

  1. What are the gnome, code, and core snaps?

Core is required for snap to function, it has the program's core runtime. The gnome snaps are a pack of basic apps (calculator, system-monitor, etc). The base gnome-3-34 snaps are dependencies for the various gnome apps. Code is vscode.

  1. The snaps in /var/lib/snapd/snaps are taking up 2.0 GB of space on my disk right now. I want to clear up space

Snap lets you easily roll-back to previous versions in case you want to. This leads to a lot of disk space being taken up, especially if an app and its dependencies are heavy. The other answer details how to limit this.

  1. I've installed discord and spotify. Will deleting the discord and spotify snaps lead to any issues with opening those applications

Yes, if discord and spotify are installed via snap removing those files will result in the applications being removed (or broken, in this case).

  1. I'm not sure if deleting these snaps is safe (if so, can I just run sudo rm -rf *?)

If you delete the snaps properly (through snap remove) yes, most of them can be removed. Removing files manually with sudo rm is dangerous. Some programs have files littered around the system and removing only part of them can cause issues and, sometimes, may need a reinstall to fix.
If a package is installed through a manager (snap in this case), you should always uninstall it via the same manager.

Since you removed files manually, snap can't find all the parts it needs to function and fails. You'll want to reinstall it with the following (note this will likely remove config files for snap and its programs, if that is an issue back them up):

sudo apt purge snapd
sudo apt install snapd
snap install discord spotify code [...]
5
  • Thank you so much! I'm not sure if I need to back up config files for snap. Why might I want to?
    – silkthyme
    Jun 9 '20 at 0:17
  • @silkthyme You probably don't need to, some apps keep stuff like login information or config settings in your home directory. Apps like Discord or Spotify save everything on their servers anyway, so really the only thing that might be lost in your case is active vscode extensions or themes.
    – GammaGames
    Jun 9 '20 at 1:43
  • Thanks, I see. Where are the config files located?
    – silkthyme
    Jun 9 '20 at 3:26
  • @silkthyme They would be somewhere in your home directory, something like /home/[username]/snap/[app]. You can find more info here: askubuntu.com/a/762405/831221
    – GammaGames
    Jun 9 '20 at 14:12
  • I don't know how it's possible, but I didn't do anything and VSCode is back. And I can open it again.
    – silkthyme
    Jun 11 '20 at 23:17
3

Yes it is safe to free up some space by deleting the the snap cache in /var/lib/snapd/snaps/ when the folder grows large.

Try this:

sudo apt purge snapd

This should actually remove that dir and all traces of snaps on your system.

More snap versions are stored by the system after snap package updates. Meaning that for each installed snap package that had updates, you could have several revisions stored on your system, thus taking up quite a bit of disk space.

There is a snap option (starting with snapd version 2.34), called refresh.retain, to set the maximum number of a snap's revisions stored by the system after the next refresh, which can be set to a number between 2 and 20. You can change this from the default value of 3 to 2 by using:

sudo snap set system refresh.retain=2

But what if you want to remove all versions kept on the system for all snap packages that had updates?

Follow This link for more information.

7
  • Can you respond to my other questions? > What are the gnome, code, and core snaps? > I've installed discord and spotify. Will deleting the discord and spotify snaps lead to any issues with opening those applications?
    – silkthyme
    Jun 2 '20 at 22:21
  • Yes you can remove them without issue. If you want to retain any of the cache files in use, check if the folders are empty. If they are proceed to remove them. If they are not empty, check file properties for some of them and look at when they were last accessed. This should tell you if those files have been in use recently by any other software. Should be safe to remove those folders if they haven't been accessed recently. Using your file manager (nautilus, on my system) you can right click on the file, then select Properties. Look for Accessed. Jun 2 '20 at 22:41
  • Bad news. I removed the discord and spotify snaps as you said, and now I can no longer open those applications. Gonna have to re install.
    – silkthyme
    Jun 4 '20 at 3:32
  • Also, now I'm getting this error after trying to reinstall: snap install discord error: cannot perform the following tasks: - Automatically connect eligible plugs and slots of snap "discord" (internal error: auto-connect of &{"discord:sound-themes" "gtk-common-themes:sound-themes"} failed: snap "gtk-common-themes" has no slot named "sound-themes")
    – silkthyme
    Jun 4 '20 at 3:38
  • Please try purging those packages and try again Jun 4 '20 at 18:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.