4

I don't remember having done anything fancy on my computer recently, but I can't run apt-get install anymore

$ sudo apt-get install phantomjs
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:
 libnspr4 : Breaks: libnspr4:i386 (!= 4.10.7-0ubuntu0.12.04.1) but 4.10.10-0ubuntu0.12.04.1 is to be installed
 libnspr4:i386 : Breaks: libnspr4 (!= 4.10.10-0ubuntu0.12.04.1) but 4.10.7-0ubuntu0.12.04.1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

$ sudo apt-get install -f
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:
  linux-headers-3.2.0-83-generic gir1.2-timezonemap-1.0 node-node-uuid linux-image-3.2.0-89-generic realpath efibootmgr diffstat linux-headers-3.2.0-70-generic
  linux-headers-3.2.0-65-generic linux-headers-3.2.0-26-generic libdmraid1.0.0.rc16 libdebconfclient0 linux-headers-3.2.0-91-generic linux-headers-3.2.0-86-generic linux-headers-3.2.0-26
  linux-headers-3.2.0-63 linux-headers-3.2.0-64 linux-headers-3.2.0-70 linux-headers-3.2.0-65 linux-headers-3.2.0-72 linux-headers-3.2.0-67 linux-headers-3.2.0-68 linux-headers-3.2.0-74
  linux-headers-3.2.0-69 linux-headers-3.2.0-80 linux-headers-3.2.0-75 linux-headers-3.2.0-76 linux-headers-3.2.0-77 linux-headers-3.2.0-83 linux-headers-3.2.0-84 linux-headers-3.2.0-79
  linux-headers-3.2.0-90 linux-headers-3.2.0-91 linux-headers-3.2.0-86 linux-headers-3.2.0-87 linux-headers-3.2.0-88 linux-headers-3.2.0-89 linux-headers-3.2.0-68-generic kpartx-boot
  libopts25 libv8-3.7.12.22 linux-headers-3.2.0-89-generic quilt autogen linux-headers-3.2.0-76-generic linux-tools-3.2.0-90 linux-tools-3.2.0-91 linux-tools-3.2.0-89
  linux-headers-3.2.0-63-generic linux-headers-3.2.0-84-generic linux-headers-3.2.0-79-generic kpartx linux-image-3.13.0-63-generic rdate linux-headers-3.13.0-63
  linux-headers-3.2.0-87-generic libssl-dev libdebian-installer4 linux-headers-3.2.0-74-generic linux-headers-3.2.0-69-generic libopts25-dev libssl-doc linux-image-3.2.0-90-generic
  zlib1g-dev apt-clone linux-headers-3.13.0-63-generic linux-headers-3.2.0-77-generic libev4 libv8-dev linux-headers-3.2.0-64-generic libc-ares2 linux-headers-3.2.0-90-generic libev-dev
  linux-headers-3.2.0-72-generic linux-headers-3.2.0-67-generic archdetect-deb dmraid libc-ares-dev python-pyicu linux-headers-3.2.0-88-generic linux-headers-3.2.0-80-generic
  linux-headers-3.2.0-75-generic linux-image-3.2.0-91-generic libllvm3.0:i386
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libnspr4
The following packages will be upgraded:
  libnspr4
1 upgraded, 0 newly installed, 0 to remove and 212 not upgraded.
2 not fully installed or removed.
Need to get 0 B/141 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
dpkg: error processing libnspr4 (--configure):
 libnspr4:amd64 4.10.7-0ubuntu0.12.04.1 cannot be configured because libnspr4:i386 is in a different version (4.10.10-0ubuntu0.12.04.1)
dpkg: error processing libnspr4:i386 (--configure):
 libnspr4:i386 4.10.10-0ubuntu0.12.04.1 cannot be configured because libnspr4:amd64 is in a different version (4.10.7-0ubuntu0.12.04.1)
Errors were encountered while processing:
 libnspr4
 libnspr4:i386
E: Sub-process /usr/bin/dpkg returned an error code (1)

$ apt-cache policy libnspr4 libnspr4:i386
libnspr4:
  Installed: 4.10.7-0ubuntu0.12.04.1
  Candidate: 4.10.10-0ubuntu0.12.04.1
  Version table:
     4.10.10-0ubuntu0.12.04.1 0
        500 http://archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages
 *** 4.10.7-0ubuntu0.12.04.1 0
        100 /var/lib/dpkg/status
     4.8.9-1ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
libnspr4:i386:
  Installed: 4.10.10-0ubuntu0.12.04.1
  Candidate: 4.10.10-0ubuntu0.12.04.1
  Version table:
 *** 4.10.10-0ubuntu0.12.04.1 0
        500 http://archive.ubuntu.com/ubuntu/ precise-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/main i386 Packages
        100 /var/lib/dpkg/status
     4.8.9-1ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ precise/main i386 Packages

$ sudo apt-get install libnspr4=4.10.10-0ubuntu0.12.04.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be upgraded:
  libnspr4
1 upgraded, 0 newly installed, 0 to remove and 140 not upgraded.
5 not fully installed or removed.
Need to get 0 B/141 kB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing libnspr4 (--configure):
 libnspr4:amd64 4.10.7-0ubuntu0.12.04.1 cannot be configured because libnspr4:i386 is in a different version (4.10.10-0ubuntu0.12.04.1)
dpkg: error processing libnspr4:i386 (--configure):
 libnspr4:i386 4.10.10-0ubuntu0.12.04.1 cannot be configured because libnspr4:amd64 is in a different version (4.10.7-0ubuntu0.12.04.1)
dpkg: dependency problems prevent configuration of libnss3:
 libnss3 depends on libnspr4 (>= 4.8.6); however:
  Package libnspr4 is not configured yet.
dpkg: error processing libnss3 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libnss3:i386:
 libnss3:i386 depends on libnspr4 (>= 4.8.6); however:
  Package libnspr4:i386 is not configured yet.
dpkg: error processing libnss3:i386 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libnss3-1d:
 libnss3-1d depends on libnss3 (= 2:3.21-0ubuntu0.12.04.2); however:
 No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                           No apport report written because the error message indicates its a followup error from a previous failure.
                        Package libnss3 is not configured yet.
dpkg: error processing libnss3-1d (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 libnspr4
 libnspr4:i386
 libnss3
 libnss3:i386
 libnss3-1d
E: Sub-process /usr/bin/dpkg returned an error code (1)

Can someone tell me how to fix this problem? I made some attempts but I have no idea :(

Braiam
  • 67,791
  • 32
  • 179
  • 269

2 Answers2

6

You must ensure that both the 32bit (libnspr4:i386) and 64bit (libnspr4) builds of a library are present in the same version.

For whatever reason (only partial upgrade or installed a PPA maybe?) only one architecture got upgraded and the other not, it seems.

The 64bit build is still stuck at an older version which is not even downloadable any more. We upgrade it to the same version as the 32bit build from the updates/main repository:

sudo apt-get install libnspr4=4.10.10-0ubuntu0.12.04.1

This should resolve the conflicts.


Update:

As my first attempt did not work, we're now going to force-remove both architectures of the package while leaving all packages that depend on them installed and then cleanly reinstall them.

You should close all running stuff and do nothing in between the removing and installing, because I don't know which of your applications depend on this and could possibly crash while it's missing.

Then run the following commands in this sequence:

sudo apt-get autoclean
sudo dpkg --remove --force-depends libnspr4 libnspr4:i386
sudo apt-get install -f

Additionally to keep the package system in good shape and free some space, I recommend to also run these commands. They will remove outdated cached binary installation packages from your disk and remove old packages that are no longer required, including some old kernels:

sudo apt-get autoclean
sudo apt-get autoremove
Byte Commander
  • 107,489
  • thanks for helping. I've added the output of the command to my question because it failed :'( – Sebastien Lorber Mar 03 '16 at 11:43
  • Okay, that's strange. We're now going to force-remove both architectures of the package and then cleanly reinstall them. You should close all running stuff and do nothing in between the removing and installing, because I don't know which of your applications depend on this and could possibly crash while it's missing. Run sudo dpkg --remove --force-depends libnspr4 libnspr4:i386 to remove both, leaving their depending packages installed, and then immediately sudo apt-get install -f to fix the broken dependencies again. I hope this will install the correct versions. – Byte Commander Mar 03 '16 at 12:55
  • You should have run sudo apt-get autoclean before that to make sure the outdated version is not available from the local package cache any more. – Byte Commander Mar 03 '16 at 12:57
  • awesome! this seemed a very scary command to execute as i've read these libs are related to threads but it worked! thank you – Sebastien Lorber Mar 03 '16 at 13:46
  • Is there any reason to downvote this answer? It worked and correctly fixed the cause of the problem. It's not even a dirty hack, it's a clean fix. Where's the problem? Whoever decided to downvote shall please add an explanation. Thanks. :-/ – Byte Commander Mar 04 '16 at 19:03
  • It is certainly not me! – Sebastien Lorber Mar 05 '16 at 09:37
2

Your problem is that both i386 and amd64 versions of the packages have to be identical in both architectures, you need to make them match. Instead of trying to remove the packages, which is a bad idea, you may want to download and install both of them:

apt-get download libnspr4:amd64 libnspr4:i386
sudo dpkg --force-depends-version -i libnspr4*.deb

This will assure you that both packages are installed without dependency problems that you may have to fix later.

Braiam
  • 67,791
  • 32
  • 179
  • 269