Unable to locate package error in Ubuntu

Fixing Unable to Locate Package Error in Ubuntu

Sagar Sharma
Sagar Sharma

Table of Contents

There are times when you try to install a package using apt and it gives you an error saying "E: Unable to locate package".

The same happened when I tried installing Hadoop on Ubuntu:

Unable to locate package error in Ubuntu

There are several reasons why it could happen and in this tutorial, I will walk you through major reasons and how you can overcome them.

How to fix locate package error on Ubuntu

Here, I will share 4 major reasons behind this error:

  • The package name is incorrect
  • The repository cache is not updated  
  • The package is not available for your version or in the Ubuntu repository
  • You're using an inactive version of Ubuntu

So let's start with the first one.

1. The package name is correct

Trust me, in most cases, this is the main culprit behind this error.

For example, the other day, I was trying to install the ping command in Ubuntu, and generally, anyone would use sudo apt install ping. Right?

In my case, the package was named iputils-ping so instead of using sudo apt install ping, I had to use the following:

sudo apt install iputils-ping

Also, remember, package names are case-sensitive which means iputils-ping and Iputils-ping are two different things.

Another good idea would be to learn how to search packages in Ubuntu so you know the exact names while installing packages in Ubuntu.

2. Repositories are not updated

Whenever you update the repositories in Ubuntu, it creates a local cache that contains information related to packages.

But if you have a fresh install of Ubuntu or a docker container that doesn't save the last state then you will this error.

And to solve this, all you have to do is update local repositories using the following:

sudo apt update 

Once done, you can install your favorite packages without any issues!

3. Package is not available

There are two possibilities on whether the package is available for your system or not:

  1. The package is only available through Universe, multiverse, third-party repository, or PPA.
  2. The package is not available for your Ubuntu version.

Let's discuss the first situation.

The package is not available in the default repository

Ubuntu has 4 repositories: Main, Universe, Multiverse, and Restricted.

But it is not always the case where your package will be found in the 4 of those repositories.

For example, if you try to install VSCode in Ubuntu, you have to add their repository to your system and if you don't, it will show the same error:

unable to install VSCode in Ubuntu

Also, there are packages that are made available only through PPA.

And if you want to check whether the package is available for any of the four repositories, then, you can use the apt-cache command in the following manner:

apt-cache policy package_name

The package is not available for your Ubuntu version

Whenever you update your system to the latest version, you may have to compromise on your favorite software.

First, let's find out what version you have using the following command:

lsb_release -a
Find ubuntu version

Once you find your version, visit the Ubuntu packages site:

Enter distribution details and package name:

Look for package on ubuntu packages

Once you do that, it will list supported distributions for that package.

And when I searched for Shutter which is one of the best screenshot tools in Linux, I got to know that my current distribution does not support Shutter at all:

Distribution is not supported

This was my reason for getting an error!

4. You are using an inactive version of Ubuntu

Ubuntu offers two release cycles: LTS (long-term support) and regular.

The LTS version is supported for 5 years whereas the regular edition is only for the 9 months. Whatever you are using but if it is out of support, then, Ubuntu won't let you install any new package.

For your reference, here, I installed Ubuntu 17.04 which is discontinued, and tried installing GIMP which is quite popular and available for Linux since its release:

It won't even let you update your repositories!

But what if none of this is valid for you?

Yes, it is possible too!

There are some packages like topgrade which is an excellent tool to update packages from multiple package managers at once. And it can only be installed with the npm package manager.

Furthermore, there are packages, which can only be installed with their deb package like google chrome!

And some can only be installed by building from scratch.

Wrapping Up...

This was a quick tutorial on what are the possible reasons behind unable to locate the package.

And I hope you will find this guide helpful in troubleshooting this error.

Sagar Sharma

Sagar Sharma

A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.