MSSQL server failed on Ubuntu on Windows 10

I’ve been getting errors with MSSQL server on Ubuntu on Windows 10. The error,

Failed to connect to bus: No such file or directory

dpkg: error processing package mssql-server (–remove):

subprocess installed post-removal script returned error exit status 1

Processing triggers for libc-bin (2.23-0ubuntu5) …

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

I managed to fix it in the end by

Of course, you should try uninstalling correctly first, which is latter of the two

I’ve included remove Microsoft GPG key and un-register the Microsoft SQL Server Ubuntu repository. For more read Microsoft doc.