1

Thanks in Advance, i want to remove a broken package mongodb-org-server. During installation, i installed using

sudo apt-get install mongodb

but when m removing it, it gets stuck on mongodb-org-server and says that

The following packages will be REMOVED:
mongodb-org-server*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 26.6 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 218521 files and directories currently installed.)
Removing mongodb-org-server (3.0.15) ...
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action "stop" failed.
dpkg: error processing package mongodb-org-server (--remove):
 subprocess installed pre-removal script returned error exit status 5
Errors were encountered while processing:
 mongodb-org-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

i have tried all these commands, but no useful results were noticed

sudo apt-get --purge remove mongodb-org-server
sudo apt-get autoclean
sudo dpkg --remove --force-remove-reinstreq mongodb-org-server

please help me out..!

  • 1
    You already solved your problem with dpkg --remove --force-remove-reinstreq mongodb-org-server...but have now created another. You must remove all those files manually now. That egg cannot be un-cracked. – user535733 Dec 30 '17 at 5:50
  • Your original problem was pretty simple: Failed to stop mongod.service: Unit mongod.service not loaded. You merely needed to restart/re-enable the service, or (16.04 and newer) explicitly disable the service using systemd. – user535733 Dec 30 '17 at 5:52
9

I had this problem before and in the end I had to go into mongodb-org-server.prerm (in /var/lib/dpkg/info/) and commented out the lines where it tries to stop the mongod.service, before using apt-get to remove it.

  • Worked for me on Ubuntu 18.04 – ralston3 Sep 13 '18 at 2:24
  • Also worked for me, good tip by the way. I would never realize it myself – Yago Azedias Dec 5 '18 at 11:07
  • @ZigguratOfUr How did you find out that you had to go into mongodb-org-server.prerm file? Awesome tip! Thanks!! :-) – Ashfaq Feb 15 at 15:02

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.