Upgrade Mongo shell 3.6.3 to 4.2 AWS Ubuntu 18.04

We initially were using DocumentDB and have switched to Mongo native. I am not havig much luck getting the shell to upgrade to 4.2, it still shows 3.6.3 after adding http://repo.mongodb.org/apt/ubuntuxenial/mongodb-org/4.2 multiverse as a repo and attempting a upgrade

:wave:

Hi @MARVIN_FRANCOIS and welcome to the community forums.

Are you getting an error when you run your apt update command? When you run mongo --version is it showing 3.6.3 or 4.2.x?

after much gnashing of teeth, I think I got it to install, at least it shows as being version 4.2, but apt still shows that the install had an issue:

Reading package lists... Done

Building dependency tree
Reading state information… Done
Correcting dependencies… Done
The following packages were automatically installed and are no longer required:
libboost-iostreams1.65.1 libgoogle-perftools4 libpcrecpp0v5 libsnappy1v5 libstemmer0d libtcmalloc-minimal4 mongo-tools mongodb-server-core
Use ‘sudo apt autoremove’ to remove them.
The following additional packages will be installed:
mongodb-org-mongos mongodb-org-server mongodb-org-tools
The following NEW packages will be installed:
mongodb-org-mongos mongodb-org-server mongodb-org-tools
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 0 B/85.7 MB of archives.
After this operation, 248 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database … 176638 files and directories currently installed.)
Preparing to unpack …/mongodb-org-server_4.2.7_amd64.deb …
Unpacking mongodb-org-server (4.2.7) …
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_4.2.7_amd64.deb (–unpack):
trying to overwrite ‘/usr/bin/mongod’, which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack …/mongodb-org-mongos_4.2.7_amd64.deb …
Unpacking mongodb-org-mongos (4.2.7) …
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_4.2.7_amd64.deb (–unpack):
trying to overwrite ‘/usr/bin/mongos’, which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack …/mongodb-org-tools_4.2.7_amd64.deb …
Unpacking mongodb-org-tools (4.2.7) …
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-tools_4.2.7_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-org-server_4.2.7_amd64.deb
/var/cache/apt/archives/mongodb-org-mongos_4.2.7_amd64.deb
/var/cache/apt/archives/mongodb-org-tools_4.2.7_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I’m not sure how the MongoDB tools were originally installed, but did you try running the sudo apt autoremove command as suggested?

if mongo --version is reporting 4.2.7 then it seems that the upgrade happened in some form, but I would definitely look into the errors. I’m not sure why apt was having problems trying overwrite binaries. Maybe they’re owned by a different user?