Fix "E: Unable to Locate Package" on Ubuntu and Debian

By 

•

Published on

•

6 min read

A magnifying glass over a software package beside an open index-card drawer

You copy an install command, run it, and get this error from APT.

output
E: Unable to locate package rip-grep

APT looks for the requested name in its local package index. When it cannot find it, you get the error above. On Ubuntu 26.04 and Debian 13, apt prints Error: in place of E:. The apt-get command still uses E:.

This guide shows you how to refresh the index, find the correct package name, and check whether the package is available for your release.

Refresh the Package Index

Start with apt update to download fresh package lists from your configured repositories.

Terminal
sudo apt update

The update refreshes APT’s local list of available packages without upgrading anything you have installed. A fresh server image or container may start with an empty list.

Read the end of the output before retrying the install. If you see Failed to fetch or Some index files failed to download, check which repository failed. APT can use an older list for that repository if it has one. Fix the reported problem, then run sudo apt update again. For a signing-key error, see our guide to fixing NO_PUBKEY .

If every Ubuntu source fails with 404 Not Found, check whether your release has reached end of life. Some time after that date, its packages move to old-releases.ubuntu.com, and the regular mirrors stop serving it. The Ubuntu 26.04 upgrade guide shows how to point your sources at the old-releases archive and upgrade to a supported release.

Check the Package Name

Search the local index for the spelling you expect. Here, we look for ripgrep.

Terminal
apt-cache search --names-only '^ripgrep$'
output
ripgrep - Recursively searches directories for a regex pattern

The ^ and $ anchors make this an exact name search. If you know only part of a name, leave off the anchors to see related packages. Use the name from the result in your install command.

Terminal
sudo apt install ripgrep

The executable name can also differ from the package name. In this case, ripgrep installs the rg command.

If you downloaded a .deb file, give APT a path so it knows to look on disk. Run this from the download directory and replace example.deb with your filename.

Terminal
sudo apt install ./example.deb

The ./ tells APT to look in the current directory. See our guide to installing local .deb packages for other ways to pass the file path.

Check Your Release and Architecture

If the name is right but the search returns nothing, use these commands to identify your release and package architecture.

Terminal
grep -E '^(ID|VERSION_ID|VERSION_CODENAME)=' /etc/os-release
dpkg --print-architecture

On an Ubuntu 26.04 ARM system, the output looks like this:

output
VERSION_ID="26.04"
VERSION_CODENAME=resolute
ID=ubuntu
arm64

Package pages and repository entries refer to a release by its codename, resolute in this example. The last line is the package architecture. Most PCs and cloud servers print amd64.

Search Ubuntu Packages or Debian Packages for the exact name, then check the release and architecture on the package page. For example, php8.5 is in the Ubuntu 26.04 (resolute) archive. Ubuntu 24.04 (noble) ships PHP 8.3, so sudo apt install php8.5 fails there with the same error. If a tutorial uses a package from a different release, look for installation instructions written for your release. Mixing releases can pull in incompatible dependencies.

Enable the Repository That Provides the Package

If the package page lists a build for your release and architecture, check which component or repository provides it. Ubuntu 26.04 publishes ripgrep in universe, while Debian 13 publishes it in main.

Ubuntu Repository Components

If the package is in universe and that component is missing from your Ubuntu sources, enable it with add-apt-repository:

Terminal
sudo add-apt-repository universe

The command adds universe to every Ubuntu source entry, including the security entry, and then refreshes the package index.

To edit the sources by hand instead, open the file with sudoedit.

Terminal
sudoedit /etc/apt/sources.list.d/ubuntu.sources

Add universe to the Components: line in each Ubuntu archive stanza where it is missing, including the security stanza. Keep the existing components. For an entry with all four Ubuntu components, the line reads as follows.

txt
Components: main universe restricted multiverse

Packages in multiverse need that component in the same way. Some packages also arrive after release. On Ubuntu 24.04, openjdk-25-jdk exists only in the noble-updates and noble-security suites, so APT finds it only when universe is enabled for one of those suites.

On Ubuntu 22.04, the standard sources are usually in /etc/apt/sources.list. Add the missing component at the end of the relevant active deb lines there.

After saving the file, refresh the index and use apt-cache policy to see what APT would install.

Terminal
sudo apt update
apt-cache policy ripgrep

Here is the result from Ubuntu 26.04 with universe enabled.

output
ripgrep:
  Installed: (none)
  Candidate: 15.1.0-1ubuntu1
  Version table:
     15.1.0-1ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu resolute/universe arm64 Packages

The Candidate: line shows the version APT would install. The line below the version identifies the source, resolute/universe in this example. Once you see a candidate, retry the install.

Debian and Third-Party Sources

On Debian, check the source files under /etc/apt/sources.list.d/ and any entries in /etc/apt/sources.list. Match the component on the Debian package page, such as main or non-free-firmware, to the source for your release.

Some packages come from the software vendor’s repository. For example, docker-ce is published in Docker’s own APT repository. If that source is missing or failed to update, follow the installation guide for Ubuntu or Debian .

If a third-party repository returns a 404 or has no Release file, check whether its owner supports your release before changing the source entry. See our guide to adding an APT repository on Ubuntu for source configuration.

When There Is No Installation Candidate

If APT reports Package ... has no installation candidate, it recognizes the name but has no installable version selected. For example, Ubuntu 26.04 has no package named python.

Terminal
sudo apt install python
output
Package python is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python-is-python3


Error: Package 'python' has no installation candidate

The line under However the following packages replace it: names the package to install instead, python-is-python3 in this case. When APT lists no replacement, check apt-cache policy for that package. If it shows Candidate: (none), check your repository configuration and any version pinning. If APT already found a candidate and reports unmet dependencies instead, see our guide to fixing broken packages .

Conclusion

If the package is not in any archive for your release, check the project’s own installation page for an official APT repository, Snap, or .deb download before adding a source from another release. The apt cheatsheet keeps the search and policy commands from this guide in one place.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page