Fear of the big hammer

Standard

Power tools are dangerous. Be afraid of power tools. For instance “rm”, in a MacPorts installation is a power tool that can easily mutilate your set up.

I was annoyed at the amount of junk that got thrown into my system by a MacPorts install poorly done two years ago. So, I started removing packages (ports) here and there. At one point, Zeus knows why, I ended up at /opt/local/lib and noticed that I had a few “flavors” of libiconv. Like a n00b, I thought that the one with a number “2” in the file name was a file too many; maybe it had been left behind from the installation of a previous version. So, I did the unthinkable and “rm”-ed it.

It just so happened that that file was the newer version of the library, which was required by ns-3. What followed were almost two hours of irritation, as I tried to reinstall the libiconv port. It couldn’t be removed because of a large number of dependencies, so I tried “upgrade” and “build” and a few other port commands, but no luck: libiconv.2.dylib wasn’t being rebuilt. The next great idea I had was to try to remove all the dependents on libiconv, so that I could remove the library package and succeed at rebuilding from a fresh install. Considering that many of these dependents were involved in other long dependency chains, it turned out to be a bad proposition.

There was only one option left: the BIG hammer, the power-power-tool: do a port -f uninstall and assume that I could reinstall libiconv before any of its dependents would notice. The -f should scare any one once bitten. If I had been foolish enough to remove the libiconv.2.dylib in the broader of my Mac OS X installation, I’d gave gone up the proverbial creek. This was only MacPorts, though, so I thought it would be worth the risk. It was. I followed the uninstall with port clean libiconv, then with port install libiconv and voilĂ , I was back in business. ns-3 running happily again.

A post that was helpful in this venture can be found here – it taught me about otool(1) and reminded me of file(1), two commands that self-respecting hackers should keep in mind for the future. I have so much faith that this is good knowledge that I wrote this post out of selfishness first and foremost. Wanting to share it with you was only a side effect; sorry!