Azure – apt-get dist-upgrade failing on mssql-tools and msodbcsql17 packages, ubuntu 16.04

aptazuredependenciesdriversubuntu-16.04

I did regular upgrade of packages as always and something broke, cant even purge the packages due broken dependencies. The server is Ubuntu 16.04 on Azure. We are using MySQL on this server, so this package could be just Azure thing?

Output bellow:

You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
mssql-tools : Depends: msodbcsql17 (>= 17.0.0.1) but it is not installed
Depends: msodbcsql17 (< 17.1.0.0) but it is not installed
E: Unmet dependencies. Try using -f.

And when I do apt-get -f install as it was in most cases advised the output is:

apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
msodbcsql17
The following NEW packages will be installed:
msodbcsql17
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
6 not fully installed or removed.
Need to get 3,760 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 msodbcsql17 amd64 17.0.1.1-1 [3,760 kB]
Fetched 3,760 kB in 0s (15.1 MB/s)
Preconfiguring packages ...
(Reading database ... 153677 files and directories currently installed.)
Preparing to unpack .../msodbcsql17_17.0.1.1-1_amd64.deb ...
Unpacking msodbcsql17 (17.0.1.1-1) ...
dpkg: error processing archive /var/cache/apt/archives/msodbcsql17_17.0.1.1-1_amd64.deb (--unpack):
trying to overwrite '/usr/lib/libmsodbcsql-17.so', which is also in package msodbcsql 17.0.1.1-1
Errors were encountered while processing:
/var/cache/apt/archives/msodbcsql17_17.0.1.1-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried following the documentation and deleting the driver itself as stated:
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server

So I want either to fix it or completely remove it and return 13.1.9.2-1 version for mssql-tools. Due that apt-get is now bugged and cant install anything on that server.

Thanks in advance

Best Answer

The new msodbcsql17 package does not correctly conflict with v17 of the old msodbcsql package. You can't have both installed. You can have the old v13 version of msodbcsql installed. For me, I just wanted the new one so I did:

$ sudo dpkg -P msodbcsql

to purge the conflicting package manually which is what the new msodbcsql17 should be doing, but is not. Afterwards you can run:

$ sudo apt -f install

and complete the install of any pending packages.

Microsoft notes the incompatibility here:

https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server