5

I noticed an interesting phenomenon and I am looking for an explanation. On my Ubuntu system, dpkg-query cannot find some uninstalled packages which apt-cache can find. For instance,

dpkg-query -l libssl-dev

gives me:

dpkg-query: no packages found matching libssl-dev

while:

apt-cache show libssl-dev

finds the package information. At the same time, dpkg-query can locate other uninstalled packages, e.g. gimp and show their status as uninstalled. Why are some packages not visible to dpkg-query?

  • What does dpkg-query -f '${db:Status-Abbrev}\t${Package}\n' --show gimp libssl-dev say? – muru Aug 02 '15 at 05:17
  • un gimp dpkg-query: no packages found matching libssl-dev, so again, gimp is found, and libssl-dev is not. – Andrzej Pronobis Aug 02 '15 at 05:18
  • Uninstalled != purged: you've probably installed Gimp before and later uninstalled (but not purged) it, so its configuration files remain on your computer. On the other hand, libssl-dev has either never been installed or completely removed (with apt-get remove --purge), so there are no indications of its existence left that dpkg could find. – n.st Aug 02 '15 at 07:47
  • Unfortunately, that's not the case. The problem occurs on a clean system before gimp was installed. It also occurs after installing libssl-dev and then uninstalling it (not purging) using apt-get remove libssl-dev. – Andrzej Pronobis Aug 02 '15 at 15:20

1 Answers1

4

Basically, dpkg-query shows you what is installed on your system, or even packages which has been installed on your system and then been removed at some point.

Interestingly enough, if a package uses a dependency of another package, dpkg may list them as installed even though one of them was never fully installed on the system.

But apt is used to download packages from the repositories defined in your sources.list and sources.d/* directory.

in other words, apt-cache shows the packages that "could be installed" on your system not the ones already installed/uninstalled.

  • 1
    I don't think that is the answer. As I said in my question, gimp not being installed, is still found by dpkg-query and reported as not installed. So dpkg-query is aware of not installed packages. – Andrzej Pronobis Aug 02 '15 at 15:21
  • if you've installed gimp in some point, it will be listed in dpkg. But if you've never installed gimp on your machine, maybe another package used Gimp's libraries as a dependency and that's why you see it in dpkg – AliReza Mosajjal Aug 02 '15 at 15:35
  • 1
    That seems to be the case indeed. I looked up reverse dependencies of gimp and libssl-dev and there is one package that suggests gimp that is installed, while no installed packages list as dependency libssl-dev. Would be great if you could add your comment to your answer for anyone who runs into my problem in the future. – Andrzej Pronobis Aug 02 '15 at 19:31
  • would be nice to mark the answer as the correct one, too. So anyone who runs into the problem know the correct answer :) – AliReza Mosajjal Aug 03 '15 at 06:35
  • you are most welcome – AliReza Mosajjal Aug 03 '15 at 07:07