0

I'm using ubuntu 20.04. I tried to install mongodb but can not. I tried some way but not effective. So I tried sudo apt update & sudo apt upgrade. But when I run upgrade, Terminal return Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: mongodb-server : Depends: mongodb-server-core (>= 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3) but it is not installed Depends: mongodb-server-core (< 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3.1~) but it is not installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). Then I run sudo apt --fix-broken install, still error.

***Reading package lists... Done

Building dependency tree
Reading state information... Done Correcting dependencies... Done The following additional packages will be installed: mongodb-server-core The following NEW packages will be installed: mongodb-server-core 0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded. 9 not fully installed or removed. Need to get 0 B/21,6 MB of archives. After this operation, 77,8 MB of additional disk space will be used. Do you want to continue? [Y/n] (Reading database ... 202200 files and directories currently installed.) Preparing to unpack .../mongodb-server-core_1%3a3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3_amd64.deb ... Unpacking mongodb-server-core (1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3) ... dpkg: error processing archive /var/cache/apt/archives/mongodb-server-core_1%3a3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3_amd64.deb (--unpa ck): trying to overwrite '/usr/bin/mongod', which is also in package mongodb-org-server 5.0.9-2 dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Errors were encountered while processing: /var/cache/apt/archives/mongodb-server-core_1%3a3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3_amd64.deb

E: Sub-process /usr/bin/dpkg returned an error code (1)***

I also try remove mongodb in apt but it said E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Help me. Thanks

kiman
  • 101
  • Your output shows that installation is currently being blocked by trying to overwrite '/usr/bin/mongod', which is also in package.... This suggests that you have tried to install several ways, possibly from different sources, and have neglected to clean up properly after failed attempts. Your current problem is caused by the leftovers from those failed attempts. The patience to keep track of what you did and thereby to clean up properly is rewarded by a working mongodb. If you don't know how to clean up, then I suppose you could backup any data and reinstall to start clean. – user535733 Jul 12 '22 at 13:14

1 Answers1

0

It is literally telling you what to do next:

sudo apt --fix-broken install

Issue this command and wait for it to finish and it should work fine.

Also it looks like the internal state of apt is inconsistent, two packages are trying to install the same file and apt does not know to handle that. Once apt --fix-broken install is finished, que in

sudo apt update
sudo apt upgrade