0

My goal is to check if a package has been installed, and if not, install it.

A package exists:

dpkg -l | grep arangodb3
rc  arangodb3    3.4.11-1  amd64     a multi-model NoSQL database

But:

$ sudo apt remove arangodb3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'arangodb3' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 46 not upgraded.

How can this be? And how to fix it?

2

The rc status at the start of the dpkg -l output means that the package is already removed, but its configuration remains. So apt remove has nothing to do.

You can remove it entirely by purging its configuration:

sudo apt purge arangodb3

My goal is to check if a package has been installed, and if not, install it.

Then you probably should just install it: if it’s already installed, it won’t be re-installed (although it will be upgraded if necessary), if it’s not, it will be.

To determine whether a package is correctly installed, run

dpkg-query -W -f '${db:Status-Status}' package

(replacing package as appropriate). If this outputs installed, the package is installed; anything else means it’s not (or not fully).

6
  • then how do I take into account presence/absense of "rc"? Or rather, how do I check if a package is installed regardless of whether or not its config-n remains? – michika Mar 3 at 15:22
  • A package is fully installed if dpkg -l shows ii at the start of the line, or rather, i in the second column. An non-installed package should not show up in dpkg -l’s output at all. – Stephen Kitt Mar 3 at 15:26
  • how do I make dpkg give me a binary response - package info or empty string - and ignore its config-n presense? – michika Mar 3 at 15:47
  • See the update. – Stephen Kitt Mar 3 at 16:36
  • dpkg-query -W -f '${db:Status-Status}' "nginx" -- nothing, although it's installed fully, with ii. – michika Mar 3 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.