Broken APT on WSL 18.04

17,904

If you want a quick and dirty fix, you can remove the offending apt hook by typing:

sudo rm -rf /etc/apt/apt.conf.d/20snapd.conf
Share:
17,904

Related videos on Youtube

173467321476C
Author by

173467321476C

Updated on September 18, 2022

Comments

  • 173467321476C
    173467321476C almost 2 years

    I am having problems with apt on my WSL installation of Ubuntu 18.04.

    Whenever I try to install a package with apt I get this:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required: [...]
    
    E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Success
    E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Success
    

    I believe snapd/snappy is the culprit here, but I have not been able to find a way to solve this. Afaik snapd is not supported on WSL and I assume it's been installed in an update.

    I am hoping to find a solution that won't require me to nuke the whole installation and having to spend hours setting everything up fresh.

    Thanks in advance.

    EDIT: original output from apt --version was apt 1.6.8 (amd64). An upgrade to 1.7.0 (amd64) did not seem to fix the issue.

    • Melebius
      Melebius over 5 years
      Related: bugs.launchpad.net/ubuntu/+source/apt/+bug/1776218 Should be fixed already…
    • 173467321476C
      173467321476C over 5 years
      I've read that thread, but it doesn't really help me in any way. This problem appeared recently for me (after using the wsl installation for a good 4-5 months.) Is there any way to update apt itself (without apt upgrade)?
    • Melebius
      Melebius over 5 years
      Yes, you could use dpkg. Download the required package from packages.ubuntu.com, then install it manually. You should also add the output of apt --version to your question.
    • 173467321476C
      173467321476C over 5 years
      Ok, it output apt 1.6.8 (amd64) so I downloaded and upgraded to apt 1.7.0 (amd64) after resolving dependencies I still have issues.
  • 173467321476C
    173467321476C over 5 years
    Quick and dirty, but it did the trick.
  • sathya
    sathya over 4 years
    well done. it works like a charm.
  • JPR
    JPR over 4 years
    Don't forget to backup your file before removing
  • Skynet
    Skynet about 4 years
    It would have better if you explain it a bit, like what you're up to. What is in that file just things like that, it would have much easier to understand. Thanks however it resolved my issue +1 for that.
  • greg
    greg almost 4 years
    as JPR said make a copy sudo cp 20snapd.conf 20snapd.conf~, install abd, and then rename the copy to the original sudo mv 20snapd.conf~ 20snapd.conf.
  • Phil Gilmore
    Phil Gilmore almost 3 years
    I just ran into this on Ubuntu 20.04 as well and this fixed it. sudo mv 20snapd.conf 20snapd.conf-removed.