Error installing zlib1g-dev

Solution 1:

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.