Cannot remove snaps on Ubuntu 21.04

I’m running an upgraded 21.04, not a fresh install, and had snaps installed prior to upgrade. I cannot remove any snaps from the system, always getting the same error message:

ERROR cannot remove snap file "chromium", will retry in 3 mins: incorrect number of tail fields, expected 3 but found 4

I can install them fine, but had troubles running Chromium (and others) until I figured out it works if I connect them to gnome-3-28-1804.

david@bulldog:~$ snap version
snap    2.49.2+git1056.g68bd611
snapd   2.49.2+git1056.g68bd611
series  16
ubuntu  21.04
kernel  5.11.0-13-generic

I’m not very savvy when it comes to snaps, so just let me know what you need.

Thanks in advance!

looks like you are using the edge channel of snapd … better do a

snap refresh --stable snapd

to get back to a non-development version

All right, I did, but the problem remains. I initially upgraded cause I thought maybe it would fix the problem.

david@bulldog:~$ sudo snap refresh --stable snapd
2021-04-04T21:23:24+03:00 INFO Waiting for automatic snapd restart...
snapd 2.49.1 from Canonical✓ refreshed
david@bulldog:~$ sudo snap remove vobsub2srt
2021-04-04T21:23:43+03:00 ERROR cannot remove snap file "vobsub2srt", will retry in 3 mins: incorrect number of tail fields, expected 3 but found 4

Can you attach the output of cat /proc/self/mountinfo ?

Certainly.

david@bulldog:~$ cat /proc/self/mountinfo
23 28 0:21 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw
24 28 0:22 / /proc rw,nosuid,nodev,noexec,relatime shared:15 - proc proc rw
25 28 0:5 / /dev rw,nosuid,noexec,relatime shared:2 - devtmpfs udev rw,size=3993484k,nr_inodes=998371,mode=755,inode64
26 25 0:23 / /dev/pts rw,nosuid,noexec,relatime shared:3 - devpts devpts rw,gid=5,mode=620,ptmxmode=000
27 28 0:24 / /run rw,nosuid,nodev,noexec,relatime shared:5 - tmpfs tmpfs rw,size=805308k,mode=755,inode64
28 1 8:2 / / rw,relatime shared:1 - ext4 /dev/sda2 rw,errors=remount-ro
29 23 0:6 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw
30 25 0:25 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw,inode64
31 27 0:26 / /run/lock rw,nosuid,nodev,noexec,relatime shared:6 - tmpfs tmpfs rw,size=5120k,inode64
32 23 0:27 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,size=4096k,nr_inodes=1024,mode=755,inode64
33 32 0:28 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup2 rw,nsdelegate
34 32 0:29 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,xattr,name=systemd
35 23 0:30 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:12 - pstore pstore rw
36 23 0:31 / /sys/firmware/efi/efivars rw,nosuid,nodev,noexec,relatime shared:13 - efivarfs efivarfs rw
37 23 0:32 / /sys/fs/bpf rw,nosuid,nodev,noexec,relatime shared:14 - bpf none rw,mode=700
38 32 0:33 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,rdma
39 32 0:34 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,cpuset
40 32 0:35 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,hugetlb
41 32 0:36 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,blkio
42 32 0:37 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,devices
43 32 0:38 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,cpu,cpuacct
44 32 0:39 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,memory
45 32 0:40 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:23 - cgroup cgroup rw,net_cls,net_prio
46 32 0:41 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:24 - cgroup cgroup rw,pids
47 32 0:42 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:25 - cgroup cgroup rw,freezer
48 32 0:43 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:26 - cgroup cgroup rw,perf_event
49 24 0:44 / /proc/sys/fs/binfmt_misc rw,relatime shared:27 - autofs systemd-1 rw,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=18023
50 25 0:45 / /dev/hugepages rw,relatime shared:28 - hugetlbfs hugetlbfs rw,pagesize=2M
51 25 0:19 / /dev/mqueue rw,nosuid,nodev,noexec,relatime shared:29 - mqueue mqueue rw
52 23 0:7 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime shared:30 - debugfs debugfs rw
53 23 0:11 / /sys/kernel/tracing rw,nosuid,nodev,noexec,relatime shared:31 - tracefs tracefs rw
54 23 0:46 / /sys/fs/fuse/connections rw,nosuid,nodev,noexec,relatime shared:32 - fusectl fusectl rw
55 23 0:20 / /sys/kernel/config rw,nosuid,nodev,noexec,relatime shared:33 - configfs configfs rw
126 28 7:2 / /snap/chromium/1523 ro,nodev,relatime shared:70 - squashfs /dev/loop2 ro
129 28 7:4 / /snap/core/10908 ro,nodev,relatime shared:72 - squashfs /dev/loop4 ro
132 28 7:1 / /snap/chromium/1539 ro,nodev,relatime shared:74 - squashfs /dev/loop1 ro
135 28 7:3 / /snap/core/10859 ro,nodev,relatime shared:76 - squashfs /dev/loop3 ro
138 28 7:0 / /snap/chromium/1536 ro,nodev,relatime shared:78 - squashfs /dev/loop0 ro
141 28 7:5 / /snap/gnome-3-34-1804/66 ro,nodev,relatime shared:80 - squashfs /dev/loop5 ro
144 28 7:7 / /snap/core18/1997 ro,nodev,relatime shared:82 - squashfs /dev/loop7 ro
147 28 7:6 / /snap/discord/121 ro,nodev,relatime shared:84 - squashfs /dev/loop6 ro
150 28 7:8 / /snap/gnome-3-28-1804/145 ro,nodev,relatime shared:86 - squashfs /dev/loop8 ro
153 28 7:10 / /snap/discord/122 ro,nodev,relatime shared:88 - squashfs /dev/loop10 ro
156 28 7:9 / /snap/core/10958 ro,nodev,relatime shared:90 - squashfs /dev/loop9 ro
253 28 7:11 / /snap/snapd/11588 ro,nodev,relatime shared:92 - squashfs /dev/loop11 ro
257 28 7:12 / /snap/vlc/1700 ro,nodev,relatime shared:94 - squashfs /dev/loop12 ro
261 28 7:13 / /snap/gtk-common-themes/1514 ro,nodev,relatime shared:96 - squashfs /dev/loop13 ro
265 28 7:14 / /snap/gnome-3-26-1604/100 ro,nodev,relatime shared:98 - squashfs /dev/loop14 ro
269 28 7:15 / /snap/vlc/2103 ro,nodev,relatime shared:100 - squashfs /dev/loop15 ro
273 28 7:16 / /snap/gtk-common-themes/1513 ro,nodev,relatime shared:102 - squashfs /dev/loop16 ro
277 28 7:17 / /snap/snapd/11402 ro,nodev,relatime shared:104 - squashfs /dev/loop17 ro
159 28 7:18 / /snap/vobsub2srt/34 ro,nodev,relatime shared:106 - squashfs /dev/loop18 ro
160 28 7:20 / /snap/snap-store/518 ro,nodev,relatime shared:108 - squashfs /dev/loop20 ro
165 28 8:1 / /boot/efi rw,relatime shared:110 - vfat /dev/sda1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
168 28 7:19 / /snap/hello-world/29 ro,nodev,relatime shared:112 - squashfs /dev/loop19 ro
171 28 7:21 / /snap/core18/1988 ro,nodev,relatime shared:114 - squashfs /dev/loop21 ro
174 28 7:22 / /snap/gnome-3-28-1804/128 ro,nodev,relatime shared:116 - squashfs /dev/loop22 ro
177 28 7:23 / /snap/snap-store/498 ro,nodev,relatime shared:118 - squashfs /dev/loop23 ro
180 28 8:4 / /home rw,relatime shared:120 - ext4 /dev/sda4 rw
183 28 7:24 / /snap/gnome-3-34-1804/60 ro,nodev,relatime shared:122 - squashfs /dev/loop24 ro
186 28 7:25 / /snap/vobsub2srt/27 ro,nodev,relatime shared:124 - squashfs /dev/loop25 ro
189 28 7:26 / /snap/gnome-3-26-1604/98 ro,nodev,relatime shared:126 - squashfs /dev/loop26 ro
379 28 0:56 / /mnt/wd rw,relatime shared:704 - cifs //192.168.1.109/WD (USB) rw,vers=3.0,cache=strict,username=censored,uid=1000,noforceuid,gid=132,noforcegid,addr=192.168.1.109,file_mode=0771,dir_mode=0771,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1
398 28 0:57 / /mnt/data0 rw,relatime shared:714 - cifs //192.168.1.109/Public/data0 rw,vers=3.0,cache=strict,username=censored,uid=1000,noforceuid,gid=132,noforcegid,addr=192.168.1.109,file_mode=0771,dir_mode=0771,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1
417 28 0:58 / /mnt/data1 rw,relatime shared:724 - cifs //192.168.1.109/Public/data1 rw,vers=3.0,cache=strict,username=censored,uid=1000,noforceuid,gid=132,noforcegid,addr=192.168.1.109,file_mode=0771,dir_mode=0771,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1
436 28 0:59 / /mnt/censored rw,relatime shared:734 - cifs //192.168.1.109/censored/ rw,vers=3.0,cache=strict,username=censored,uid=1000,noforceuid,gid=1000,noforcegid,addr=192.168.1.109,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1
455 27 0:60 / /run/user/1000 rw,nosuid,nodev,relatime shared:744 - tmpfs tmpfs rw,size=805304k,nr_inodes=201326,mode=700,uid=1000,gid=1000,inode64
475 455 0:61 / /run/user/1000/gvfs rw,nosuid,nodev,relatime shared:755 - fuse.gvfsd-fuse gvfsd-fuse rw,user_id=1000,group_id=1000
1416 28 0:62 / /var/lib/docker/overlay2/fc3a23bd9f178ab6d21da36ace958142f7203cf5eb0ee2c062c64ec4e1994d9c/merged rw,relatime shared:766 - overlay overlay rw,lowerdir=/var/lib/docker/overlay2/l/FKAWHKJVBVDFIJYA6LD5PNMUW3:/var/lib/docker/overlay2/l/DYBHKR6XIQG3G4V4D7ZSOGXO7F:/var/lib/docker/overlay2/l/CYQUKOGFJ4KG56MYVLTSXDBWFJ,upperdir=/var/lib/docker/overlay2/fc3a23bd9f178ab6d21da36ace958142f7203cf5eb0ee2c062c64ec4e1994d9c/diff,workdir=/var/lib/docker/overlay2/fc3a23bd9f178ab6d21da36ace958142f7203cf5eb0ee2c062c64ec4e1994d9c/work
1445 28 0:63 / /var/lib/docker/overlay2/c93d1a2da149dfa96bfdf4f3b836e5f6ae5ad323b0a21c15ed9822140d457f2a/merged rw,relatime shared:776 - overlay overlay rw,lowerdir=/var/lib/docker/overlay2/l/E2XLZWRHSOM37WAU2OPSUJ5N4O:/var/lib/docker/overlay2/l/UJTQEHU6SNZSAQCASVPSW5FHR4:/var/lib/docker/overlay2/l/LJM277O7JPH6F3JIG5ZPW3VIYJ:/var/lib/docker/overlay2/l/QCP76XQKVUYILVYSVIZI6QXNCJ:/var/lib/docker/overlay2/l/MW3222UOIYJ5TXVDJPTJQP4ZNW:/var/lib/docker/overlay2/l/LHUDAGWCCZ235XCAA7LJLQGKWM:/var/lib/docker/overlay2/l/V4SWEPKI73HBLKEFFWKGJI2DLK:/var/lib/docker/overlay2/l/BQWMKPXQJ4DHZWSIYDWG2MX52N:/var/lib/docker/overlay2/l/UOQS7JEACWOIIZSGJGIACKEQCQ:/var/lib/docker/overlay2/l/HGZUJH6OJBYNDOTQCVPS76GWQW,upperdir=/var/lib/docker/overlay2/c93d1a2da149dfa96bfdf4f3b836e5f6ae5ad323b0a21c15ed9822140d457f2a/diff,workdir=/var/lib/docker/overlay2/c93d1a2da149dfa96bfdf4f3b836e5f6ae5ad323b0a21c15ed9822140d457f2a/work
1661 27 0:4 net:[4026532526] /run/docker/netns/d2ff026ed99a rw shared:786 - nsfs nsfs rw
1682 27 0:4 net:[4026532585] /run/docker/netns/8bb01dd1b466 rw shared:796 - nsfs nsfs rw
1891 455 0:90 / /run/user/1000/doc rw,nosuid,nodev,relatime shared:968 - fuse.portal portal rw,user_id=1000,group_id=1000

AFAICT this looks like a bug in the kernel? You have this entry:

379 28 0:56 / /mnt/wd rw,relatime shared:704 
-
cifs //192.168.1.109/WD (USB)
rw,vers=3.0,cache=strict,username=censored,uid=1000,noforceuid,gid=132,noforcegid,addr=192.168.1.109,file_mode=0771,dir_mode=0771,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1

The mountinfor should contain only 11 fields separated with whitespace, for this particular like there’s 12 fields. The manpage isn’t too informative:

The file contains lines of the form:

36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
(1)(2)(3)   (4)   (5)      (6)      (7)   (8) (9)   (10)         (11)

Specifically, the CIFS share name WD (USB) is what introduces an additional space. I don’t know why there is no quoting or the space hasn’t been replaced with %20 or some other encoding.

I think we may want to be less strict about parsing mountinfo. However it’s hard to tell bad input from a valid but quirky one. You can temporarily unmount the problematic share, at which point snap removal should be working again.

In my fstab it’s WD\040(USB), I suppose bash just prints the escaped char in my pastes.

Your suggestion works:

david@bulldog:~$ sudo umount /mnt/wd
david@bulldog:~$ sudo snap remove vobsub2srt
vobsub2srt removed

I’ll have to see if I can make my NAS export another volume name somehow.

Thanks for your help!

1 Like

I took a quick look at docker and podman. Both use the github.com/moby/sys/mountinfo package which has this workaround: https://github.com/moby/sys/blob/76d97006feb66cd237953a0df1e06648118cd101/mountinfo/mountinfo_linux.go#L60-L72

Looks like it’s a new thing available only in 5.11+ kernels, see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=653a5efb849aea1706648257c3c23ece82997f44

2 Likes

It’s been working fine for the past two, or so, Ubuntu releases and started when I upgraded to 21.04 with 5.11 kernel.

I’ve submitted a patch to the kernel which will be a part of 5.11.14 release. At some point the fix should be picked up by Ubuntu kernels too.