1

I am trying to install Mongodb using the command sudo apt-get install -y mongodb-org on ubuntu 16.04 after it produces the following error:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mongodb-org : Depends: mongodb-org-shell but it is not going to be installed
               Depends: mongodb-org-server but it is not going to be installed
               Depends: mongodb-org-mongos but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
phuwin
  • 3,130
  • 4
  • 26
  • 49
Gor Hakobyan
  • 11
  • 1
  • 2
  • can you please show content of /etc/apt/sources.list.d/mongodb-org-xx.list file? Or any other file, which contains repository information – Ivan Cherviakov Dec 04 '19 at 15:33
  • @IvanCherviakov here deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse – Gor Hakobyan Dec 05 '19 at 08:06
  • What happens if you try to install those dependencies separately? – Ivan Cherviakov Dec 05 '19 at 08:23
  • Just to make sure, can you also post here result of uname -a? – Ivan Cherviakov Dec 05 '19 at 08:29
  • Linux user-System-Product-Name 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux – Gor Hakobyan Dec 05 '19 at 08:31
  • https://stackoverflow.com/questions/46404622/error-while-installing-mongodb-on-ubuntu-16-04 - here people saying need to install libcurl3, worth to try – Ivan Cherviakov Dec 05 '19 at 08:36
  • Also check carefully if there any other sources file, which point to repo of mongodb, maybe different version, as name of packages same it could cause trouble when you try to request them from repos of different versions, comment with # – Ivan Cherviakov Dec 05 '19 at 08:40
  • I already saw https://stackoverflow.com/questions/46404622/error-while-installing-mongodb-on-ubuntu-16-04 , they didn't help with the solution – Gor Hakobyan Dec 05 '19 at 09:11
  • Well in the worst case purge all mongodb related packages installed, remove all lines with mongodb repo lines and try to start with official mongodb docs clean. – Ivan Cherviakov Dec 05 '19 at 09:17
  • Related: https://askubuntu.com/questions/1054292/packages-have-unmet-dependencies-on-18-04-upon-mongodb-install/1054323#1054323 – user185160 Nov 01 '21 at 19:31

5 Answers5

1

Looking at the MongoDB Documentation at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ it says to use their package not the Ubuntu APT package.

Here are the steps to use the MongoDB Package in a nutshell...

Add the APT Key:

wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -

Add the APT Sources List:

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

Update APT:

sudo apt-get update

Install the MongoDB Community Edition Package:

sudo apt-get install -y mongodb-org

Start the service:

sudo service mongod start

Log into the database using mongoshell:

mongo
barrypicker
  • 9,740
  • 11
  • 65
  • 79
  • 1
    I am still having following error: `mongodb-org : Depends: mongodb-org-database but it is not going to be installed` – alper Feb 10 '22 at 10:34
0

If someone else struggle with this issue and all the other answers didn't work...

This is what work for me:

apt-get install mongodb-org-shell
apt-get install mongodb-org-server
apt-get install mongodb-org-mongos

And then again

sudo apt-get install -y mongodb-org

Detials (run uname -a):

Linux resta-dev 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • 1
    I am having folllowing error: `mongodb-org-shell : Depends: libc6 (>= 2.29) but 2.27-3ubuntu1.4 is to be installed` – alper Feb 10 '22 at 10:35
0

I got this issue when the wrong Ubuntu version was selected. Make sure you double check that you run the correct one.

Max
  • 1
-1

Use this command to display the installed applications and their dependencies causing troubles:

sudo dpkg --configure -a

and use the following command and replace package-name with the name of the package that need to be removed

sudo dpkg --remove package-name

You are now good to go.

Antoine
  • 1,393
  • 4
  • 20
  • 26
-1

Your system already had the Ubuntu MongoDB package installed prior to installing the official mongodb-org packages. To confirm whether the host has the Ubuntu mongodb package installed, run;

sudo apt list --installed | grep mongo

If present you will need to remove all the installed mongodb-org packages by running;

sudo apt remove mongo*

Once all the MongoDB packages are removed you can now use the Official installation Guide to complete your installation