3

I am an Ubuntu newbie and would like to install zlib1g-dev on Ubuntu 16.04.3 LTS.

The command:

sudo apt-get install zlib1g-dev

ressults in the following error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies.
 zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2ubuntu4) but 1:1.2.8.dfsg-2ubuntu4.1 is to be installed
E: Unable to correct problems, you have held broken packages.

I've been searching around but I don't know how to fix this.

Some more info:

sudo apt-get -f install && sudo dpkg --configure -a
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.


apt-cache policy build-essential libc6-dev libc-dev g++ libpcap-dev libpcap0.8-dev libpq-dev krb5-multidev comerr-dev libsqlite3-dev postgresql postgresql-9.3 zlib1g-dev
build-essential:
  Installed: 12.1ubuntu2
  Candidate: 12.1ubuntu2
  Version table:
 *** 12.1ubuntu2 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
libc6-dev:
  Installed: 2.23-0ubuntu9
  Candidate: 2.23-0ubuntu9
  Version table:
 *** 2.23-0ubuntu9 100
        100 /var/lib/dpkg/status
     2.23-0ubuntu3 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libc-dev:
  Installed: (none)
  Candidate: (none)
  Version table:
g++:
  Installed: 4:5.3.1-1ubuntu1
  Candidate: 4:5.3.1-1ubuntu1
  Version table:
 *** 4:5.3.1-1ubuntu1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
libpcap-dev:
  Installed: (none)
  Candidate: 1.7.4-2
  Version table:
     1.7.4-2 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main i386 Packages
libpcap0.8-dev:
  Installed: (none)
  Candidate: 1.7.4-2
  Version table:
     1.7.4-2 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libpq-dev:
  Installed: (none)
  Candidate: 9.5.2-1
  Version table:
     9.5.2-1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
krb5-multidev:
  Installed: (none)
  Candidate: 1.13.2+dfsg-5
  Version table:
     1.13.2+dfsg-5 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
comerr-dev:
  Installed: (none)
  Candidate: 2.1-1.42.13-1ubuntu1
  Version table:
     2.1-1.42.13-1ubuntu1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libsqlite3-dev:
  Installed: (none)
  Candidate: 3.11.0-1ubuntu1
  Version table:
     3.11.0-1ubuntu1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
postgresql:
  Installed: (none)
  Candidate: 9.5+173
  Version table:
     9.5+173 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main i386 Packages
postgresql-9.3:
  Installed: (none)
  Candidate: (none)
  Version table:
zlib1g-dev:
  Installed: (none)
  Candidate: 1:1.2.8.dfsg-2ubuntu4
  Version table:
     1:1.2.8.dfsg-2ubuntu4 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
ksl
  • 804
  • 3
  • 10
  • 14

3 Answers3

8

I just had the same issue trying to install some dependencies for compiling Ruby.

The easiest way out of this misery is to note down the package and version on the second to last line: zlib1g and 1:1.2.8.dfsg-2ubuntu4, then issue the following command:

$ sudo apt install zlib1g=1:1.2.8.dfsg-2ubuntu4

This will downgrade zlib1g to the required version, and the install should succeed afterwards.

SeinopSys
  • 180
  • 1
  • 7
0

Try examine with this :

sudo aptitude install libssl-dev

Get the message :

The following packages have unmet dependencies:
zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2ubuntu4) but 1:1.2.8.dfsg- 
2ubuntu4.1 is installed.
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1)     libssl-dev [Not Installed]
2)     zlib1g-dev [Not Installed]

Accept this solution? [Y/n/q/?]

Then 'e' and downgrade your zlib1g-dev.

Does that fix your problem?

Félicien
  • 1,183
-3

This pertains more to debian than Ubuntu but, if your having trouble get apt get update and upgrade, follow these steps. This is required in order to install libssl and all the other cool things you want.

Copy sources.list to a backup #cp /etc/apt/sources.list /etc/apt/sources.list.bk

Modify the apt sources file by using Nano #nano /etc/apt/sources.list

Replace ALL of the lines with the following:

deb http://cdn-fastly.deb.debian.org/debian/ jessie main
deb-src http://cdn-fastly.deb.debian.org/debian/ jessie main

deb http://security.debian.org/ jessie/updates main deb-src http://security.debian.org/ jessie/updates main

deb http://archive.debian.org/debian jessie-backports main deb-src http://archive.debian.org/debian jessie-backports main

deb http://ftp.us.debian.org/debian stable main contrib

Save the file and then run the following commands:

sudo apt-get -o Acquire::Check-Valid-Until=false update
sudo apt-get -o Acquire::Check-Valid-Until=false upgrade

8 hours to figure all that out. Your welcome :)

zx485
  • 2,426