Weird snap behavior. It is there but won’t work. I tried a couple of different containers. Will try on my home machines later. Did the snaps break all of a sudden or is it my imagination they worked before in a container?

Weird snap behavior. It is there but won’t work. I tried a couple of different containers.
Will try on my home machines later. Did the snaps break all of a sudden or is it my imagination they worked before in a container?

root@AD-TEST:~# snap
bash: snap: command not found
root@AD-TEST:~# apt install snap
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
The following NEW packages will be installed:
snap
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 377 kB of archives.
After this operation, 2756 kB of additional disk space will be used.
Get:1 Index of /ubuntu jammy/universe amd64 snap amd64 2013-11-29-11 [377 kB]
Fetched 377 kB in 0s (915 kB/s)
Selecting previously unselected package snap.
(Reading database … 18879 files and directories currently installed.)
Preparing to unpack …/snap_2013-11-29-11_amd64.deb …
Unpacking snap (2013-11-29-11) …
Setting up snap (2013-11-29-11) …
root@AD-TEST:~# snap list
bash: snap: command not found
root@AD-TEST:~# snap
bash: snap: command not found
root@AD-TEST:~#
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy

root@AD-TEST:~# apt install snap
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
snap is already the newest version (2013-11-29-11).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

That’s because the package is snapd not snap.

Note that installing snapd will make you run into another set of bugs which we’re still waiting for Ubuntu to actually fix… To work around them, you’ll have to run:

root@c1:~# apt-get install --yes snapd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apparmor dbus-user-session liblzo2-2 squashfs-tools
Suggested packages:
  apparmor-profiles-extra apparmor-utils zenity | kdialog
The following NEW packages will be installed:
  apparmor dbus-user-session liblzo2-2 snapd squashfs-tools
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 38.6 MB of archives.
After this operation, 174 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 apparmor amd64 2.13.3-7ubuntu5.3 [502 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 dbus-user-session amd64 1.12.16-2ubuntu2.3 [9424 B]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 liblzo2-2 amd64 2.10-2 [50.8 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 squashfs-tools amd64 1:4.4-1ubuntu0.3 [117 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 snapd amd64 2.58+20.04.1 [37.9 MB]
Fetched 38.6 MB in 2s (18.9 MB/s)
Preconfiguring packages ...
Selecting previously unselected package apparmor.
(Reading database ... 26244 files and directories currently installed.)
Preparing to unpack .../apparmor_2.13.3-7ubuntu5.3_amd64.deb ...
Unpacking apparmor (2.13.3-7ubuntu5.3) ...
Selecting previously unselected package dbus-user-session.
Preparing to unpack .../dbus-user-session_1.12.16-2ubuntu2.3_amd64.deb ...
Unpacking dbus-user-session (1.12.16-2ubuntu2.3) ...
Selecting previously unselected package liblzo2-2:amd64.
Preparing to unpack .../liblzo2-2_2.10-2_amd64.deb ...
Unpacking liblzo2-2:amd64 (2.10-2) ...
Selecting previously unselected package squashfs-tools.
Preparing to unpack .../squashfs-tools_1%3a4.4-1ubuntu0.3_amd64.deb ...
Unpacking squashfs-tools (1:4.4-1ubuntu0.3) ...
Selecting previously unselected package snapd.
Preparing to unpack .../snapd_2.58+20.04.1_amd64.deb ...
Unpacking snapd (2.58+20.04.1) ...
Setting up liblzo2-2:amd64 (2.10-2) ...
Setting up apparmor (2.13.3-7ubuntu5.3) ...
Created symlink /etc/systemd/system/sysinit.target.wants/apparmor.service → /lib/systemd/system/apparmor.service.
Reloading AppArmor profiles 
Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
Setting up dbus-user-session (1.12.16-2ubuntu2.3) ...
Setting up squashfs-tools (1:4.4-1ubuntu0.3) ...
Setting up snapd (2.58+20.04.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.aa-prompt-listener.service → /lib/systemd/system/snapd.aa-prompt-listener.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.apparmor.service → /lib/systemd/system/snapd.apparmor.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.autoimport.service → /lib/systemd/system/snapd.autoimport.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.core-fixup.service → /lib/systemd/system/snapd.core-fixup.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.recovery-chooser-trigger.service → /lib/systemd/system/snapd.recovery-chooser-trigger.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service.
Created symlink /etc/systemd/system/cloud-final.service.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service.
Created symlink /etc/systemd/system/multi-user.target.wants/snapd.service → /lib/systemd/system/snapd.service.
Created symlink /etc/systemd/system/timers.target.wants/snapd.snap-repair.timer → /lib/systemd/system/snapd.snap-repair.timer.
Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /lib/systemd/system/snapd.socket.
Created symlink /etc/systemd/system/final.target.wants/snapd.system-shutdown.service → /lib/systemd/system/snapd.system-shutdown.service.
snapd.failure.service is a disabled or a static unit, not starting it.
snapd.mounts-pre.target is a disabled or a static unit, not starting it.
snapd.mounts.target is a disabled or a static unit, not starting it.
snapd.snap-repair.service is a disabled or a static unit, not starting it.
Processing triggers for libc-bin (2.31-0ubuntu9.14) ...
Processing triggers for systemd (245.4-4ubuntu3.22) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for dbus (1.12.16-2ubuntu2.3) ...
Processing triggers for mime-support (3.64ubuntu1) ...

root@c1:~# sed -i "s/lxd/incus/g" /lib/apparmor/rc.apparmor.functions 

root@c1:~# mkdir -p /etc/systemd/system/snapd.apparmor.service.d/
root@c1:~# (
cat << EOF
[Service]
ExecStartPre=/usr/bin/mkdir -p /run/WSL
EOF
 ) > /etc/systemd/system/snapd.apparmor.service.d/override.conf

root@c1:~# reboot
root@c1:~#

After that, snaps work as expected:

root@c1:~# snap install hello-world
2024-01-11T20:43:00Z INFO Waiting for automatic snapd restart...
hello-world 6.4 from Canonical✓ installed
root@c1:~# hello-world
Hello World!