8

I'm using Ubuntu for Windows, and have been for some time. /etc/debian_version names it as buster/sid. As a result of recent suspected disk corruption, /usr/lib/x86_64-linux-gnu/libapt-private.so.0.0.0 appears to have been replaced by a same-sized file containing only (binary) zeroes.

This breaks apt and prevents its self-repair, of course.

I have been given a copy of the same file by colleagues. However, I cannot find a way to replace the one in my filesystem. Even launching bash with Windows Administrator privileges, and then acquiring root privileges within that shell, does not permit me to rename or replace the file.

It's highly discouraged to attempt to alter these files from Windows tools such as File Explorer and the cmd shell - however, even running cmd with Administrator privileges gives "Access is denied."

How can I replace this library file under Ubuntu for Windows? Is it even possible? Google and StackExchange searches have not been helpful.

4
9

So, my WSL got broken because of Windows Defender detecting my libapt-private.so.0.0.0 as a trojan. [insert ironic comment here]

(UPDATE: This SO answer reports some news from Microsoft on the issue)

Solution

First of all, the most annoying thing was that every attempt to delete or move the library gave "Permission Denied" error. In order to prevent this, make sure you are operating as Administrator: open your WSL shell from an elevated cmd/powershell and work there.

What follows is (almost) the implementation of Imaginecat22's answer.

  1. Find your version of apt

    $ dpkg -l apt
    
    [. . .]
    ||/ Name                              Version               Architecture          Description
    +++-=================================-=====================-=====================-=======================================================================
    ii  apt                               1.6.11                amd64                 commandline package manager
    

    write down the value of Architecture.

  2. Download .deb package

    Most packages can be found with the Ubuntu package search.

    Not all versions are available there though, so you may need to download manually:

    • use a web browser to open:

      https://launchpad.net/ubuntu/+source/apt/<VERSION>/

      Replace <VERSION> with the value of Version returned in step 1, e.g.:

      https://launchpad.net/ubuntu/+source/apt/1.6.11/

    • Find the Builds section and select the build that matches the Architecture value from step 1.

    Copy the URL to download the file apt_<VERSION>_<ARCHITECTURE>.deb. From your WSL Linux shell download the package:

        $ wget https://launchpad.net/ubuntu/+source/apt/1.6.11/+build/16829590/+files/apt_1.6.11_amd64.deb
    
  3. Install package using dpkg

    $ dpkg -i apt_1.6.11_amd64.deb
    

Should overwrite your previous version and the broken library with it.

6
  • Thanks, Salvioner, but (as I've noted elsewhere) when I use dpkg to install the .deb, I get "unable to make backup link of './usr/lib/x86_64-linux-gnu/libapt-private.so.0.0.0' before installing new version: Permission denied". That's using sudo for the dpkg command, and even from within a bash window launched with Windows Administrator permissions. (Or from bash invoked from a cmd shell launched with Windows Administrator permissions.) – Jon Green Dec 11 '19 at 9:53
  • 1
    OK, I'm going to facepalm now, because I missed the bit about Windows Defender. When I did notice it, I went into Defender, noted it had quarantined the file, and marked it for removal. It wasn't actually removed until I'd rebooted. Then I could copy a known good version into place, and all's now good. Thanks! – Jon Green Dec 11 '19 at 10:16
  • You need to be root to run dpkg -i. The last command should be dpkg -i apt_1.6.11_amd64.deb – Shoan Dec 12 '19 at 1:10
  • @JonGreen that's weird, I just needed to open cmd as an Admin to fix the backup link issue. Or at least, I managed (after making a backup cp of the library) to remove the file, after that the installation completed successfully. – Salvioner Dec 12 '19 at 9:05
  • @JonGreen kinda interesting the fact that Defender requires to reboot the PC to remove the detected file. Is a reboot required also for restoring files? Because I tried simply to ignore the file from the Defender UI, but it completely ignored all my attempts to remove or restore it. It never says to reboot, but maybe that's exactly what I should have done. – Salvioner Dec 12 '19 at 9:07
1

My Windows Defender just removed my sudo_libutil.so.0.0.0. I managed to fix the problem without reinstalling any packages.

I posted the answer to superuser.com here

0

I've just ran into the same problem. Just get yourself a new apt.deb package and manually reinstall it with dpkg -i

I got mine from https://packages.ubuntu.com/bionic/apt

Then run apt update, upgrade, probably fix-broken, etc.

1
  • Thanks @crisdias - unfortunately, I'd tried that without success - got a bunch of errors I listed in chat.stackexchange.com/rooms/101982/… but tl;dr is that it threw permission errors when trying to replace that file. – Jon Green Dec 10 '19 at 11:35
0

Hey I was having exactly the same problem - to the point where I was watching your discussion and following along. I created a Stack Overflow account just to let you know I figured it out! (This is my first post lol) The trick is to install (or like me have installed) WSL on another machine, then scp the libapt-private.so.0.0.0 file over straight to the directory!

After that, I typed sudo apt-get -f install and it ran like normal :) Hope this helps!

Not the answer you're looking for? Browse other questions tagged or ask your own question.