ubuntu 16.04 install snapd problem

10,674

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.
Share:
10,674

Related videos on Youtube

descogle
Author by

descogle

Updated on September 18, 2022

Comments

  • descogle
    descogle over 1 year

    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
    
    • guiverc
      guiverc almost 6 years
      I would check your sources (what have you added there, and do you have trusty (14.04) sources?) - you should be getting 2.39.9 (packages.ubuntu.com/search?keywords=snapd) and not have a trusty (14.04) version. Can you add apt-cache policy snapd to your question.
    • descogle
      descogle almost 6 years
      @guiverc, I added information that you asked to my question.
    • guiverc
      guiverc almost 6 years
      I would comment out your 'trusty' sources; I can't see what they can provide you extra (with a tiny change of complications) unless you know of a reason to use them. I comment them out (put a # at start of line in /etc/apt/sources.list for those lines) as its easy to put them back if you need to reverse it (I also leave a "#- lines marked this way were commented out 2018-06-28 guiverc" (ie. doco explaining why) which I also do when I add sources (so I can remember why). Once command out; you can sudo apt update then try again.
    • guiverc
      guiverc almost 6 years
      The trusty version (2.33) was given priority as it's a higher number than the correct xenial version (2.32.9) as 2.33>2.32.9 according to apt's logic. Removing the 'trusty' sources should fix... (don't forget to sudo apt-get update first)
    • descogle
      descogle almost 6 years
      @guiverc well i'll tried to remove the souse, and now i see that ubuntu is trying to install the correct verions of file but still have an error due instalation Errors were encountered while processing: /var/cache/apt/archives/snapd_2.32.9_amd64.deb
    • guiverc
      guiverc almost 6 years
      Like the prior one, I'd do a apt-cache policy snapd to see where it's coming from (no need to post it here). all versions of Ubuntu should be the same (except trusty & cosmic) [packages.ubuntu.com/search?keywords=snapd]. I'd try sudo apt -f install again, maybe sudo apt install --reinstall snapd (I'd be somewhat guided by what I saw in apt-cache policy output)... let me know if problem persists; I'm heading to bed :)
    • doug
      doug almost 6 years
      enable xenial-proposed, update sources & see if snapd will upgrade. If that happens to work install and or open synaptic > Origins. See if there are any other trusty packages installed. If so replace with xenial, in either case then remove the trusty repos from your sources. It was not a good or in any way useful idea to have them.
    • descogle
      descogle almost 6 years
      Thanks you for answers @doug, @guiverc, I finnaly get the point of my problem, the last step is to clean the var/lib/dpkg/info from all that concerns snap like this sudo rm ./snapd* and then sudo apt-get update && sudo apt-get upgrade and finish with sudo apt install --reinstall snapd and that's to the god of linux get the output of the snap --version command like: snap 2.32.9 snapd 2.32.9 series 16 ubuntu 16.04 kernel 4.4.0-130-generic