How to repair empty /snap/bin directory

Hello! I’ve recently found myself with an empty /snap/bin directory on Kubuntu 22.04 (see below for this came about). How would I go about repairing this? There were ca. 40 snaps installed IIRC, but I have no exact list of which snaps were installed. It would have to be whatever snaps Kubuntu 22.04 installs.

Any help greatly appreciated!

If it’s of any relevance, what happened was that I wanted to use the tree command, found it not present. So I used Kubuntu 22.04’s Discover tool to install the tree snap. It installed tree v1.8.1 I think. I used it on an old backup disk mounted externally, which contains linux and windows backups from years ago:

/media/user/ drwxr-xr-x 4 root root 4096 Sep 13 2015 ‘Linux Backups’/ drwxrwxrwx 1 user user 4096 Jun 3 2020 ‘Win Backups’/

Somehow, tree could not deal with this directory structure, so I used Discover again to remove the tree package, and installed a newer version via apt install, and got version v2.0.2. , which worked fine. At that point I discovered that the /snap/bin was empty. While it is not impossible that I did something stupid myself, I could find no evidence for that in the konsole’s command history.

Hi ! @haimo.

When you execute this command :

snap list

What do you obtain ?

Hi!
This is what I get from $ snap list:

Name Version Rev Tracking Publisher Notes bare 1.0 5 latest/stable canonical** base core 16-2.61.4-20240607 17200 latest/stable canonical** core core20 20240416 2318 latest/stable canonical** base gnome-3-38-2004 0+git.efb213a 143 latest/stable/… canonical** - gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical** - snapd 2.63 21759 latest/stable canonical** snapd

Sorry about the formatting, I don’t know how to get the same tabular appearance here as in the terminal. Where can I find a info/tutorials for the composer?

You can put the output in these open and close backticks (triple backticks [start, end]) :

``` your long message/log ```

1 Like
Name               Version             Rev    Tracking         Publisher   Notes
bare               1.0                 5      latest/stable    canonical✓  base
core               16-2.61.4-20240607  17200  latest/stable    canonical✓  core
core20             20240416            2318   latest/stable    canonical✓  base
gnome-3-38-2004    0+git.efb213a       143    latest/stable/…  canonical✓  -
gtk-common-themes  0.1-81-g442e511     1535   latest/stable/…  canonical✓  -
snapd              2.63                21759  latest/stable    canonical✓  snapd

OK, that looks better. Thanks!

1 Like

Well @haimo !

Can you show the output of this command ? :face_with_monocle:

sudo systemctl status snapd

I would like to have the output of this too :

sudo snap list --all

$ sudo systemctl status snapd

[sudo] password for haimo: 
● snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2024-08-16 17:51:35 CEST; 3h 10min ago
TriggeredBy: ● snapd.socket
   Main PID: 973 (snapd)
      Tasks: 15 (limit: 9334)
     Memory: 40.2M
        CPU: 2.726s
     CGroup: /system.slice/snapd.service
             └─973 /usr/lib/snapd/snapd

Aug 16 17:51:26 pcoct snapd[973]: overlord.go:271: Acquiring state lock file
Aug 16 17:51:26 pcoct snapd[973]: overlord.go:276: Acquired state lock file
Aug 16 17:51:28 pcoct snapd[973]: daemon.go:247: started snapd/2.63+22.04ubuntu0.1 (series 16; classic) ubuntu/22.04 (amd64) linux/5.15.0-118-generic.
Aug 16 17:51:28 pcoct snapd[973]: daemon.go:340: adjusting startup timeout by 1m0s (pessimistic estimate of 30s plus 5s per snap)
Aug 16 17:51:33 pcoct snapd[973]: backends.go:58: AppArmor status: apparmor is enabled and all features are available
Aug 16 17:51:35 pcoct systemd[1]: Started Snap Daemon.
Aug 16 17:52:08 pcoct snapd[973]: stateengine.go:149: state ensure error: persistent network error: Get "https://api.snapcraft.io/api/v1/snaps/sections": dial tcp: lookup api.snapcraft.io: Temporary failure in name >
Aug 16 17:57:11 pcoct snapd[973]: storehelpers.go:923: cannot refresh: snap has no updates available: "bare", "core", "core20", "gnome-3-38-2004", "gtk-common-themes", "snapd"
Aug 16 18:15:19 pcoct snapd[973]: api_snaps.go:427: Installing snap "emacs" revision unset
Aug 16 18:21:36 pcoct snapd[973]: storehelpers.go:923: cannot refresh: snap has no updates available: "bare", "core", "core20", "gnome-3-38-2004", "gtk-common-themes", "snapd"

$ snap list --all

bare               1.0                 5      latest/stable    canonical✓  base
core               16-2.61.4-20240607  17200  latest/stable    canonical✓  core
core20             20221027            1695   latest/stable    canonical✓  base,disabled
core20             20240416            2318   latest/stable    canonical✓  base
gnome-3-38-2004    0+git.6f39565       119    latest/stable/…  canonical✓  disabled
gnome-3-38-2004    0+git.efb213a       143    latest/stable/…  canonical✓  -
gtk-common-themes  0.1-81-g442e511     1535   latest/stable/…  canonical✓  -
gtk-common-themes  0.1-79-ga83e90c     1534   latest/stable/…  canonical✓  disabled
snapd              2.63                21759  latest/stable    canonical✓  snapd

Okay ! Well @haimo.

And this :

sudo snap saved

Set  Snap  Age    Version         Rev  Size    Notes
3    tree  4d06h  1.8.0+pkg-3fd6  18    692kB  auto

One snap removed :face_with_monocle:

I don’t think you can recover your lost snaps.

There seems to be no trace (except tree snap).

As I said earlier, whatever snaps where there must be those installed by Kubuntu (with exception of tree, which I installed and then removed). Is there a way to just reinstall the entire snap system from scratch with all the snaps that are in the distro by default?

And many thanks for your help & patience!

Yep ! @haimo.

If you want you can reinstall your snap package and snapd.

You can achieve this goal via this scenario :

sudo snap remove snapd

sudo snap install snapd --classic

sudo systemctl enable --now snapd.socket # Startup service

1 Like

Do not hesitate to close this topic by choosing the scenario that seems optimal for you.

Thanks !