Terminal and bash can't start with libiconv error

I just tried to start Terminal.app in Mac OS X 10.6.8, and got the following error:

 dyld: Library not loaded: /opt/local/lib/libiconv.2.dylib   Referenced
    from: /bin/bash   Reason: Incompatible library version: bash requires
    version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0

 [Process completed]

I have MacPorts installed, so I suspect somehow the libiconv version is messed up. However, since I can't start a terminal session, I don't even know how to troubleshoot or correct this error.

What should I do? Thanks.


Solution 1:

Without bash you won't be able to login in the Terminal or via ssh. You could try zsh instead but this is probably depending on the library as well.

Option 1

Open Terminal, ignore the error message in the window, press Shift-Cmd-N and run /bin/sh, /bin/zsh or /bin/csh instead of bash. Then fix the symlinks.

Option 2

Boot from the Install DVD, run Terminal from there and see whether version 8 of the library is still in /usr/lib (or use libiconv.* from the Install DVD). If yes, fix the symlinks and reboot.

OTOH as OS X 10.8 ships with libiconv.2 you might be out of luck:

lrwxr-xr-x  1 root  wheel       16 Oct 16 20:50 libiconv.2.4.0.dylib@ -> libiconv.2.dylib
-r-xr-xr-x  1 root  wheel  2113600 Oct 16 20:50 libiconv.2.dylib*
lrwxr-xr-x  1 root  wheel       20 Oct 16 20:50 libiconv.dylib@ -> libiconv.2.4.0.dylib

Option 3

Like option 1 but try to replace the MacPorts /bin/bash with the original one. I don't know how MacPorts works but the original one might still hang around as /bin/bash.orig or similar.

Option 4

Reinstall the OS from the Install DVD (doesn't impact the rest) and re-apply the OS X upgrades.