Encountering the “E: Unable to Locate Package” error message in a Linux terminal can be frustrating, especially when trying to install software or dependencies specially in Ubuntu. This error indicates that the package manager, such as apt (or may be yum), cannot find the requested package in its repositories. In this comprehensive guide, we’ll explore the possible causes of this error and provide step-by-step solutions to resolve it. Usually the error looks like this:
1 2 3 4 5 | $ sudo apt-get install <package> Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package <package> |
Obviously, your internet connection must be working.
Understanding the Error
The “E: Unable to Locate Package” error typically occurs when the package manager cannot find the specified package in its list of available packages. This can happen due to various reasons, including:
---
- Typographical errors in the package name.
- The package repository is not enabled or properly configured.
- The package has been removed from the repository.
- The package name has changed, or it belongs to a different repository.
Troubleshooting Steps
Verify that you’ve entered the correct package name without any spelling mistakes. Even a minor typo can result in the package manager being unable to locate the package.
For example, if you wrongly type mariabd instead of mariadb, even apt-search will return nothing:
1 2 | apt-search mariabd apt-search mariadb |
You may find the correct package-name (i.e. the name in the repository) using apt-cache search command too.

May be, you have to update the index:
1 | sudo apt-file update |
Sometimes, the package lists stored by the package manager may be outdated. Run the following command to update the package lists before attempting to install the package:
1 2 | sudo apt update # for APT sudo yum makecache # for YUM |
Ensure that the repository containing the package is enabled in your system’s repository configuration. Check the /etc/apt/sources.list file (for APT) or repository configuration files in /etc/yum.repos.d/ (for YUM) to verify the repository settings. For example:
1 2 | cat /etc/apt/sources.list cat /etc/yum.repos.d/ |
If you’re unsure about the correct package name or repository, you can use the package manager’s search functionality to find the package:
1 2 | apt search # for APT yum search # for YUM |
If you’re using custom repositories or third-party repositories, ensure that the repository URLs are correctly configured. Incorrect URLs or repository configurations can prevent the package manager from locating the package.
To enable all repositories (main, universe, restricted, multiverse), use the following commands:
1 2 3 4 | sudo add-apt-repository main sudo add-apt-repository universe sudo add-apt-repository restricted sudo add-apt-repository multiverse |
Verify that the package you’re trying to install is still available in the repository. Sometimes, packages are removed or renamed, leading to the “Unable to Locate Package” error. If a missing or outdated GPG key is causing the error, you can attempt to retrieve it:
1 | sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com key_id |
Replace The key_id with the real value. Then you can add PPA (Ubuntu):
1 2 | sudo add-apt-repository ppa:<repository-name> sudo apt-get update |
In some cases, the package manager’s cache may be corrupted, causing issues with package installation. Clear the package cache and update the package lists:
1 2 | sudo apt clean # for APT sudo yum clean all # for YUM |
Conclusion
The “E: Unable to Locate Package” error in Linux can be resolved by following the troubleshooting steps outlined above. By checking for typos, updating package lists, ensuring repository configuration, and verifying package availability, you can effectively troubleshoot and resolve this error. Remember to always double-check package names and repository settings to avoid encountering this error in the future. With the right approach, installing packages on Linux can be a smooth and hassle-free experience.
Tagged With wealthu8m