Wednesday, February 01, 2012

MacPorts texlive Broken by zlib 1.2.6

It's this time of the year - zlib gets updated, and things break. I run texlive latex distribution from MacPorts, and a recent update to zlib (from 1.2.5 to 1.2.6) broke texlua. When trying to activate texlive packages,  mtxrun (executed by texlua) throws the following error:

texlua PANIC: unprotected error in call to Lua API (zlib library version does not match - header: 1.2.5, library: 1.2.6)

Thus, we have to downgrade to zlib 1.2.5. I'll presume you routinely clean your outdated ports, thus it's not a simple matter of deactivating zlib 1.2.6 and reactivating the old one. That's the price one pays on being a bit OCD with that. The root of the problem is, of course, that port clean outdated does not allow selecting packages whose replacements were installed before a certain date. You'd need that functionality to only clean up ports whose upgraded replacements have hung around for a bit to prove their worth.

First, we have to determine the ports repository revision where the port got updated. The simplest way is to go to the websvn interface for macports subversion, and look up zlib there. Thus we see that 1.2.6 came to be in rev 89487. We need a revision prior to that (89486).

It's assumed that you run bash as your shell. If you don't, simply run bash before running any of the commands below.

If don't have a private ports source tree, here's how you can create one in your home directory:

mkdir -p ports/archivers
echo file://$(pwd)/ports | cat /dev/stdin "$srcconf" > "$newconf"
sudo bash -c "cat $newconf > $srcconf"
rm "$newconf"

We then check out the old zlib, and reindex the tree:

cd ~/ports
svn co -r 89486 archivers/zlib

At that point, you're ready for the downgrade:

sudo port uninstall -f zlib
sudo port clean --all zlib
sudo port install zlib +universal

If you're not interested in a universal variant, you can skip '+universal'.

You'll want to reactivate texlive (and any related packages):

texlive=$(port installed | awk '/(texlive|texlive-[^ ]+)/ { print $1 }')
sudo port deactivate -f $texlive
sudo port activate $texlive

1 comment:

  1. Thanks Kuba! I have exactly the same problem and came across your post from Google. I didn't exactly follow your route, but instead I directly checked out the old zlib and replaced the new one in the tree. Probably simpler, but might forget about it next time I `port upgrade outdated`. :)