Sunday, February 20, 2022

[SOLVED] Unable to install/remove mongodb-org on Ubuntu 18.04 Bionic - "mongodb-org-tools : Depends: mongodb-database-tools but it is not installed"

Issue

I've tried following the instructions to install mongodb, as per the mongodb.com instructions.

When I run: sudo apt-get install -y mongodb-org, I get the following:

The following packages have unmet dependencies.
 mongodb-org-tools : Depends: mongodb-database-tools but it is not going to be installed

There's a suggestion to run apt --fix-broken install. So I run it with sudo. I get the following:

The following packages were automatically installed and are no longer required:
  libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5 libtcmalloc-minimal4 libyaml-cpp0.5v5 mongo-tools
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mongodb-database-tools

Which then fails, with this error report:

Unpacking mongodb-database-tools (100.5.0) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-database-tools_100.5.0_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/mongodb-database-tools_100.5.0_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

My reading of this: trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.6.3-0ubuntu1 suggests to me that there is something in mongo-tools that is stubbornly not letting itself be removed. So I tried running sudo apt autoremove to remove the mongo-tools. Unfortunately I get the following:

The following packages have unmet dependencies.
 mongodb-org-tools : Depends: mongodb-database-tools but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

So I try apt --fix-broken install again, as recommended, but without any success. I need to find a way to get rid of that darned mongo-tools - but how? I tried following the "Uninstall MongoDB Community Edition" instructions on those on the same page I linked above.

When I enter sudo apt-get purge mongodb-org*, this forms part of the message:

The following packages were automatically installed and are no longer required:
  libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5 libtcmalloc-minimal4 libyaml-cpp0.5v5 mongo-tools mongodb-mongosh
Use 'sudo apt autoremove' to remove them.

So now I have mongo-tools and this new mongodb-mongosh? I've attempted to install again but I run into the same problems. What's the fix?


Solution

Finally got it working: I tried sudo apt-get purge mongo-tools* and sudo apt-get purge mongodb-mongosh*, and this seemed to fix things and permit an install.

For some reason, the uninstall directions in the documentation (command: sudo apt-get purge mongodb-org*) didn't remove mongo-tools. It may have been something I'd installed from another source previously.



Answered By - JimmyTheCode
Answer Checked By - Senaida (WPSolving Volunteer)