apt-get install fails with Not Found error because

2019-07-20 01:41发布

问题:

I've been attempting to install the package r-base on Ubuntu Trusty Tahr and there's a package dependency that became broken in the last week.

My commands are as follows:

apt-get update -y
apt-get dist-upgrade -y
apt-get install -y r-base-dev
...
Err http://archive.ubuntu.com/ubuntu/ trusty-security/main libpng12-dev amd64 1.2.50-1ubuntu2.14.04.1
  404  Not Found [IP: 91.189.91.23 80]
Fetched 92.8 MB in 28s (3262 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-dev_1.2.50-1ubuntu2.14.04.1_amd64.deb  404  Not Found [IP: 91.189.91.23 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c sudo apt-get install -y r-base-dev' returned a non-zero code: 100

I have attempted to pass --fix-missing and --ignore-missing but it still fails.

It appears that the package was removed on Jan 8, 2016 due to a security patch: https://launchpad.net/ubuntu/+archive/primary/+sourcepub/5711916/+listing-archive-extra

Looking at http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/ confirms that the ubuntu2.14.04.1 file is not there but 1.2.50-1ubuntu2.14.04.2 is present.

How do I fix that? My goal is to get r-base to install.

If I could somehow make it use the version "2" file instead of "1" it would presumably find the file and proceed happily, but I'm not sure how to make apt-get do that.

Alternatively, maybe it's possible to update the dependency list on my side? Or is it up to the r-base maintainers to do so?

Or third, is it possible to add a repository that still has the old package? I'm not running on an AMD processor, so I shouldn't need this particular package at runtime anyway.

Update: The solution that worked for me was to explicitly remove the package with the broken dependency, download the updated version, and re-install it before running apt-get update.

$ apt-get remove -y libpng12-0
$ curl -O http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.50-1ubuntu2.14.04.2_amd64.deb
$ dpkg -i libpng12-0_1.2.50-1ubuntu2.14.04.2_amd64.deb
$ apt-get update -y

The problem apparently doesn't have much to do with the r-base or r-base-dev packages, even though r-base-dev incidentally depends on libpng12.

回答1:

In my opinion this problem will probably fix itself in a couple of days. However if you can't wait, here's what you can do.

First, find out which version of libpng the package you want to install depends on.

$ apt-cache depends r-base
r-base
  Depends: r-base-core
  Depends: r-recommended
  Recommends: r-base-html
  Recommends: r-doc-html
  Suggests: ess
 |Suggests: r-doc-info
  Suggests: r-doc-pdf

r-base itself does not depend on libpng but r-base-core probably does.

$ apt-cache depends r-base-core | grep png
  Depends: libpng12-0

Now we want to know which specific version of libpng

$ apt-cache show r-base-core
... libpng12-0 (>= 1.2.13-4) ...

If you locate this package in Ubuntu's repositories, you can download it and try to install it manually.

$ wget <url>
$ sudo dpkg -i <filename>

and then install r-base with apt-get install r-base. However if dpkg refuses to install libpng you should not force it, because it means the package is not installable and it would break other dependencies.