Trying to install the
python-numpy package in
Debian Unstable ("Sid") I got the following error on the
liblapack3 package (seen also in this bug):
$ sudo apt-get install -f Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded. 4 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Setting up liblapack3 (3.5.0-4) ... update-alternatives: error: alternative liblapack.so.3gf can't be slave of liblapack.so.3: it is a master alternative dpkg: error processing package liblapack3 (--configure): subprocess installed post-installation script returned error exit status 2 dpkg: dependency problems prevent configuration of python-numpy: python-numpy depends on liblapack3 | liblapack.so.3; however: Package liblapack3 is not configured yet. Package liblapack.so.3 is not installed. Package lapack3 which provides liblapack.so.3 is not installed. Package atlas3-base which provides liblapack.so.3 is not installed. Package liblapack3 which provides liblapack.so.3 is not configured yet. Package libatlas3-base which provides liblapack.so.3 is not installed.
Run the following command to fix the error:
$ sudo update-alternatives --remove-all liblapack.so.3gf
And then rerun the install:
$ sudo apt-get install -f
The actual error is the following line:
update-alternatives: error: alternative liblapack.so.3gf can't be slave of liblapack.so.3: it is a master alternative
Searching for that error found this bug report which explains what went wrong: the most recent version of the package is incompatible with a very old version of the package which I must have had installed at some point in the past. If I had ever installed some version of it in the middle, then the problem would have been fixed by the automatic scripts, but for whatever reason the latest version no longer includes the code for cleaning up after that very old version.
So I had to do it myself instead.
The Debian Alternatives System allows for multiple packages to
be installed that provide the same functionality. For example, you
might have multiple versions of Java or multiple web browsers
installed, and one of them has to be the default when you run
The alternatives system is managed through the
We can ask it for information about alternatives:
$ update-alternatives --display x-www-browser x-www-browser - manual mode link currently points to /usr/bin/iceweasel /usr/bin/chromium - priority 40 /usr/bin/epiphany-browser - priority 85 slave x-www-browser.1.gz: /usr/share/man/man1/epiphany-browser.1.gz /usr/bin/iceweasel - priority 70 slave x-www-browser.1.gz: /usr/share/man/man1/iceweasel.1.gz Current 'best' version is '/usr/bin/epiphany-browser'.
Which it gets from
$ cat /var/lib/dpkg/alternatives/x-www-browser manual /usr/bin/x-www-browser x-www-browser.1.gz /usr/share/man/man1/x-www-browser.1.gz /usr/bin/chromium 40 /usr/bin/epiphany-browser 85 /usr/share/man/man1/epiphany-browser.1.gz /usr/bin/iceweasel 70 /usr/share/man/man1/iceweasel.1.gz
The alternatives are handled via symlinks:1
$ /bin/ls -ld /usr/bin/x-www-browser lrwxrwxrwx 1 root root 31 Mar 4 2010 /usr/bin/x-www-browser -> /etc/alternatives/x-www-browser $ /bin/ls -ld /etc/alternatives/x-www-browser lrwxrwxrwx 1 root root 18 Mar 4 2010 /etc/alternatives/x-www-browser -> /usr/bin/iceweasel
Since the error message complained about the alternative for
liblapack.so.3gf, let's take a look at it:
$ update-alternatives --display liblapack.so.3gf update-alternatives: warning: alternative /usr/lib/atlas-base/atlas/liblapack.so.3gf (part of link group liblapack.so.3gf) doesn't exist; removing from list of alternatives update-alternatives: warning: alternative /usr/lib/lapack/liblapack.so.3gf (part of link group liblapack.so.3gf) doesn't exist; removing from list of alternatives liblapack.so.3gf - auto mode link currently points to /usr/lib/atlas-base/atlas/liblapack.so.3gf No versions available.
It's pointing to files that don't exist, so it's clearly not doing any good. Let's get rid of it:
$ sudo update-alternatives --remove-all liblapack.so.3gf update-alternatives: warning: alternative /usr/lib/atlas-base/atlas/liblapack.so.3gf (part of link group liblapack.so.3gf) doesn't exist; removing from list of alternatives update-alternatives: warning: alternative /usr/lib/lapack/liblapack.so.3gf (part of link group liblapack.so.3gf) doesn't exist; removing from list of alternatives update-alternatives: warning: /etc/alternatives/liblapack.so.3gf is dangling; it will be updated with best choice
Now if we check again, we can see that it's gone:
$ update-alternatives --display liblapack.so.3gf update-alternatives: error: no alternatives for liblapack.so.3gf
Why did that happen?
Debian Unstable (often referred to by its codename "Sid") is an unstable distribution, which basically means Debian doesn't guarantee that installs will work. As a result, it takes a bit more work to maintain than a stable distribution like Debian's stable release or Ubuntu which is a stable distribution that is based on Debian but stays more up-to-date by having a shorter release cycle.
In this case, a Debian Stable user would presumably have had the
proper cleanup get done when performing an
dist-upgrade to the new version of Debian Stable. I only
encountered the issue because by using Debian Unstable I was taking
responsibility for keeping my packages up to date; most likely this
issue could have been avoided by doing
when uninstalling the old version of
liblapack3 to delete its
configuration files when uninstalling it.
I currently use Debian Unstable on only one of my computers because it gives me things to fiddle with to learn the details of how things work, but on the rest I just use Ubuntu or Debian Stable so I don't have to worry about them working.
These commands use
/bin/lsinstead of just
lsbecause my alias for
-Hoption which dereferences links:
$ alias ls alias ls='ls --color=auto -FHbh'
$ /bin/ls -ldH /etc/alternatives/x-www-browser -rwxr-xr-x 1 root root 110512 Mar 21 19:13 /etc/alternatives/x-www-browser
doesn't display the link target because it follows the link. ↩