Learn how to solve the installation problem of the gtk-doc-tools package in Ubuntu 18.04

In some Ubuntu distributions offered by some server rental services, will offer a mirror for the ubuntu repository. This leads sometimes with special packages to errors as they aren't on the mirror server. That's the case of the gtk-doc-tools package that seems to be unavailable on the mirrors of Serverloft, so if you try to install the package:

sudo apt-get install gtk-doc-tools

The following error will appear:

Err:41 http://ubuntu.mirror.serverloft.com/ubuntu bionic/universe amd64 gtk-doc-tools all 1.27-3
  403  Forbidden [IP: xxx.xxx.xxx.xxx 80]
Fetched 37.9 MB in 2s (15.6 MB/s)
E: Failed to fetch http://ubuntu.mirror.serverloft.com/ubuntu/pool/universe/g/gtk-doc/gtk-doc-tools_1.27-3_all.deb  403  Forbidden [IP: 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

In this tutorial, we will show you 2 ways to easily solve this problem in your Ubuntu 18.04 system.

A. Add the universe repo

In order to fix this exception easily, just register the universe repository on the system with the following command:

sudo add-apt-repository universe

The universe repository consists of free and open source software but Ubuntu doesn't guarantee of regular security updates to software in this category. Software in this category are packaged and maintained by the community. The Universe repository has a vast amount of open source software and thus it enables you to have access to a huge number of software via apt package manager.

Then, install the package as usual:

sudo apt-get install gtk-doc-tools

And theorically it should be available now and you may use it.

B. Install .deb package manually

Alternatively, you may be able to simply download the .deb package and install it through the command line. You can obtain it from a reputable website like this. For example, it's possible to obtain the file with wget in the command line with the following command:

wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gtk-doc/gtk-doc-tools_1.27-3_all.deb

Once the file is on your filesystem, install it using the dpkg command like this providing as argument the filepath to the .deb file:

sudo dpkg -i /path/to/downloaded/file/gtk-doc-tools_1.27-3_all.deb

Then run the following command:

sudo apt-get install -f

And the problem should be fixed now.

Happy coding ❤️!