Ubuntu – ubuntu 16.04 install snapd problem

16.04aptdpkgsnapsoftware installation

Having problem with installing/uninstalling snapd.

My version of snap on my Ubuntu 16.04 for some reason is not correct:

snap --version
 snap    2.31.1~14.04
 snapd   unavailable
 series  -

So I want to reinstall the snad manually using:

sudo apt-get install snapd

and get the error:

Errors were encountered while processing:
 /var/cache/apt/archives/snapd_2.33.1~14.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I decided to uninstall this version by trying to use this command:

sudo apt purge snapd ubuntu-core-launcher squashfs-tools

giving me this result:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'ubuntu-core-launcher' is not installed, so not removed
The following packages will be REMOVED:
  snapd* squashfs-tools*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 79,3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 312065 files and directories currently installed.)
Removing snapd (2.31.1~14.04) ...
Failed to stop snapd.autoimport.service: Unit snapd.autoimport.service not loaded.
Failed to stop snapd.socket: Unit snapd.socket not loaded.
Failed to stop snapd.service: Unit snapd.service not loaded.
dpkg: error processing package snapd (--purge):
 subprocess installed pre-removal script returned error exit status 5
dpkg: squashfs-tools: dependency problems, but removing anyway as you requested:
 snapd depends on squashfs-tools; however:
  Package squashfs-tools is to be removed.

Removing squashfs-tools (1:4.3-3ubuntu2.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
 snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)

Command:

apt-get -f install

won't help as well.

~$ apt-cache policy snapd

snapd:
  Installed: 2.31.1~14.04
  Candidate: 2.33.1~14.04
  Version table:
     2.33.1~14.04 500
        500 http://archive.ubuntu.com/ubuntu trusty-proposed/universe amd64 Packages
     2.32.9 500
        500 http://ru.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
     2.32.9~14.04 500
        500 http://archive.ubuntu.com/ubuntu trusty-updates/universe amd64 Packages
 *** 2.31.1~14.04 100
        100 /var/lib/dpkg/status
     2.0.2 500
        500 http://ru.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

Please, if you get any idea of what's going on and how to fix this help me 🙂

Edit:

Trusty packages that I have in a souces list:

deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

Best Answer

My version of resolving this issue:

  1. Remove/comment all unnessesary trusty sources from your /etc/apt/sources.list.
  2. Run sudo apt-get update and verify that apt-cache policy snapd is now have the Candidate: 2.32.9 that you need. try to sudo apt install --reinstall snapd.
  3. Optional. If you still have Sub-process /usr/bin/dpkg returned an error code (1) error, clean the cd var/lib/dpkg/info with sudo rm ./snapd* and reinstall the snapd sudo apt install --reinstall snapd.
  4. Verify that the Installed version is 2.32.9 snap --version.