Microsoft ODBC drivers not fully installed and no way to unistall them

15,002

Solution 1

Normally when installing a package with dpkg -i we would follow through with:

sudo apt install -f

Depending on whether dependencies are required, and to ensure that the needed dependencies are installed, but in your case, you tried removing a package that wasn't set up right in the first place. So using:

sudo apt update 
sudo dpkg --configure -a

did two things (1): update the package manager index records, (2): fix any miss configurations you had caused while trying to install and remove. The sudo apt update is a habit I usually follow to resolve issues of dependencies, and the latter command did the trick.

Solution 2

The problem you ran into is that dpkg does not resolve dependencies. This was compounded by the fact that you did not seem to read or follow the message you got "Try 'apt-get -f install'" .

Generally sudo apt-get -f install resolves the problem as apt will resolve and install the dependencies. It would have in your case as the problem wsa solved after you manually installed the dependencies.

If you were to have a problem with sudo apt-get -f install you would have to dig deeper and resolve dependencies manually.

So when installing a .deb in this way you would:

sudo dpkg -i foo.deb
sudo apt-get -f install #this command will install dependencies
sudo dpkg -i foo.deb

You were getting error messages as you were trying to remove a package that was not fully installed due to missing dependencies and you resolved the problem by installing the dependencies manually.

I am happy you fixed your problem, but next time, don't panic, read the messages.

In the future, if at all possible use a ppa and/or read up first.


Also check the detailed instructions at Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS page maintained by Microsoft:

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

Check also: apt-get how to fix very broken packages for further troubleshooting.

Share:
15,002
TPPZ
Author by

TPPZ

Updated on September 18, 2022

Comments

  • TPPZ
    TPPZ over 1 year

    I've downloaded this debian package:

    curl https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/msodbcsql_13.1.4.0-1_amd64.deb -o msodbcsql_13.1.4.0-1_amd64.deb 
    

    Then I have run the following command:

    sudo ACCEPT_EULA=Y dpkg -i msodbcsql_13.1.4.0-1_amd64.deb
    

    And I got back the following messages:

    Selecting previously unselected package msodbcsql.
    (Reading database ... 255078 files and directories currently installed.)
    Preparing to unpack msodbcsql_13.1.4.0-1_amd64.deb ...
    Unpacking msodbcsql (13.1.4.0-1) ...
    dpkg: dependency problems prevent configuration of msodbcsql:
     msodbcsql depends on unixodbc (>= 2.3.1); however:
      Package unixodbc is not installed.
    
    dpkg: error processing package msodbcsql (--install):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     msodbcsql
    

    So I realised I had to install unixodbc, so I've done sudo apt-get install unixodbc getting the following output:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    You might want to run 'apt-get -f install' to correct these:
    The following packages have unmet dependencies.
     unixodbc : Depends: libodbc1 (>= 2.3.1) but it is not going to be installed
                Depends: odbcinst1debian2 (>= 2.3.1) but it is not going to be installed
    E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
    

    At this point I started trying to remove the "half installed" package and I tried a few different approaches:

    This sudo dpkg -r msodbcsql gives:

    (Reading database ... 255091 files and directories currently installed.)
    Removing msodbcsql (13.1.4.0-1) ...
    dpkg: error processing package msodbcsql (--remove):
     subprocess installed post-removal script returned error exit status 127
    Errors were encountered while processing:
     msodbcsql
    

    This sudo apt-get autoremove gives:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be REMOVED
      msodbcsql
    0 to upgrade, 0 to newly install, 1 to remove and 10 not to upgrade.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Do you want to continue? [Y/n] Y
    (Reading database ... 255077 files and directories currently installed.)
    Removing msodbcsql (13.1.4.0-1) ...
    dpkg: error processing package msodbcsql (--remove):
     subprocess installed post-removal script returned error exit status 127
    Errors were encountered while processing:
     msodbcsql
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    This sudo apt-get --purge remove && sudo apt-get autoclean gives:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be REMOVED
      msodbcsql
    0 to upgrade, 0 to newly install, 1 to remove and 10 not to upgrade.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Do you want to continue? [Y/n] Y
    (Reading database ... 255077 files and directories currently installed.)
    Removing msodbcsql (13.1.4.0-1) ...
    dpkg: error processing package msodbcsql (--remove):
     subprocess installed post-removal script returned error exit status 127
    Errors were encountered while processing:
     msodbcsql
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    This sudo apt-get -f install gives:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be REMOVED
      msodbcsql
    0 to upgrade, 0 to newly install, 1 to remove and 10 not to upgrade.
    1 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Do you want to continue? [Y/n] Y
    (Reading database ... 255077 files and directories currently installed.)
    Removing msodbcsql (13.1.4.0-1) ...
    dpkg: error processing package msodbcsql (--remove):
     subprocess installed post-removal script returned error exit status 127
    Errors were encountered while processing:
     msodbcsql
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    I have also tried to look for some wildcards with sudo find / -name *msodbc* in the file system to hope to find a huge binary file and remove it manually, but nothing interesting came out.

    I am a bit concerned about this removal as all the previous attempts seem to give back the same error message/code and I don't find a way to either remove that "half installed" package or troubleshoot the issue.

    Is there any log file I could have a look or anything else I could do to remove that package?

    My Ubuntu details:

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 16.04.3 LTS
    Release:    16.04
    Codename:   xenial
    $ uname -a
    Linux oe-laptop 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    
    • George Udosen
      George Udosen over 6 years
      Try this sudo apt update , then sudo dpkg --configure -a
    • TPPZ
      TPPZ over 6 years
      In the meanwhile I downloaded manually some dependecies sudo apt-get download odbcinst1debian2 and sudo apt-get download odbcinst then tried to install them manually with sudo dpkg -i <DEB_PKG> but it seemed they depended on one another. However with your suggestion I was able to see dpkg was able to figure out how to clean this mess. After that I was able to install again packages with apt-get. Thanks :) Could you provide a bit of context on why that combination of commands is working?
  • TPPZ
    TPPZ over 6 years
    Thanks for the context about dpkg/apt, very useful. Those guys at Microsoft keep changing the documentation and the way they provide these deb packages. This happens too frequently. Now they sign them and provide a repository, in the past I was able to hack their own repositories and figure out how to download some debian/ubuntu packages that were not documented, then according to the package/distro versions I filled the gap (like installing a package from the debian repo into an ubuntu distro or viceversa), but I was first making sure dependencies were there. This time I forgot about them...