75

It is not unusual for a user of Ubuntu (or other distro using the apt package management tool to encounter the error:

user@box ~ $ sudo apt install x
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package x 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

E: Package 'x' has no installation candidate

There have been several questions asked concerning this on various Stack Exchange sites, for example Package network-manager-openvpn is not available on Ask Ubuntu, but these are generally about how to obtain the specific package despite the error.

I have found no package that is not found simply (though not always easily) by determining if it is still distributed, and under which repository, and ensuring the repository is in sources.list, or if the worst comes to worst, downloading a .deb file or a source file to compile.

So my question is more general, and although I am guessing it has a rather simple and therefore non-exciting answer I cannot think how to find it by conventional search engine methods, so I turn to Ask Ubuntu.

Is there a command or option I can use to determine what package(s) reference the missing package?

karel
  • 122,292
  • 133
  • 301
  • 332

4 Answers4

64

Sometimes this happens because APT just doesn't know anything about what you're talking about, but that can be solved by running:

sudo apt-get update

After running this, typically the error goes away because apt and apt-get know how to do what I ask now.

Daryn
  • 105
Wayne Workman
  • 791
  • 1
  • 5
  • 3
19

You can search for the package with apt-cache:

apt-cache search x

This will output all packages that in a way or another make a reference to x.

4

You can run this command to see all the reverse dependencies of a package (replacing PACKAGENAME with the package name):

apt-cache showpkg PACKAGENAME

What's a reverse dependency? If package X depends on package Y, then Y is a dependency of X, and X is a reverse dependency of Y.

Try removing some of the reverse dependencies by running sudo apt remove NAME.

You may also want to try removing all the configuration for the package that may not be available any more:

sudo apt purge PACKAGENAME
Flimm
  • 44,031
1

Based on previous encounters, oftentimes:

  • Substring package searching using apt search, can sometimes be a viable option, but It's also possible that the package name is unrelated, counter-intuitive, or entails intermediary characters, that gets the search process to no avail. At such case, you can google the respective name at the official repositories of the desired package or library, which usually can be conveniently referenced at the package readme or manual.
  • It's also possible that you're trying to install a command (whether it's a binary or executable file) or a module that's encompassed within another metapackage or a library, at which case apt-file search can come in handy.

However, If the package is generally unavailable in any form at the official repositories, then, as a last resort, you can alternatively look for a community-driven repository i.e. PPA that provides the software, manually installing the deb (crossing your fingers in hope for available, installable and compatible dependencies) or compile it yourself.

kqvanity
  • 135