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.

  • 3
    Did you replace /bin/bash with one that came from MacPorts? The system one does not require libiconv. Anything in /bin should not be referencing /opt/local. You could copy the /bin/bash from another machine, or reinstall 10.6. It might be worth trying to install the most recent combo updater... /bin/bash might be in there. – Alan Shutko Oct 29 '12 at 1:08

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.

  • 1
    It looks like bash won't start because of the library residing in Macports' directory. It's probably worth investigating ways to have bash not read that file before reinstalling the entire operating system. (Which, if it is a problem with PATH, would not help, because a reinstall would not clean out the home folder - and that setting.) – Jonathan Oct 29 '12 at 12:03
  • 1
    @Jonathan: It's the OS which can't execute bash. Macports may have messed up the libraries but you can't change this back without a working shell of some kind. But this gives me another idea :-) – nohillside Oct 29 '12 at 13:08
  • Finally figured it out through a combination of options 1 and 2. I used zsh to find out that it was indeed a problem with symlinks, and that the original bash was replaced. Fixing those was probably enough but I ended up reinstalling most of MacPorts anyway... Thank you for your help! – hpy Oct 31 '12 at 2:45

Open TextEdit, load the Open File dialog, and press Cmd-Shift-. (that's a dot at the end). Load the file .bash_profile

Copy, from the line which begins:

# MacPorts Installer addition

until the line which ends:

# Finished adapting your PATH environment variable for use with MacPorts.

into a separate document. Then delete those lines from the original file, and save it. Save the removed lines to a new file for safekeeping.

Your Terminal should now work, but this won't help your Macports installation. From here, you can try to troubleshoot it, or you can reinstall Macports by first removing (or backing up) /opt/local.

  • 1
    If I read the error message correctly, bash can't even be executed by the OS. Changing .bashrc doesn't help in these cases. – nohillside Oct 29 '12 at 4:26
  • Correct, but it sounds like Bash isn't starting due to a library mismatch caused by the libiconv library installed by Macports. So, it seems like Macports is too early on in the $PATH, and by removing the Macports entry in .bash_profile, that should be taken care of. – Jonathan Oct 29 '12 at 12:01
  • .bash_profile gets read by bash after bash has been started by the OS. If the OS can't even start bash (as it is the case here), changes in a file which doesn't get read anyway won't solve the problem. But it would be nice if it would... – nohillside Oct 29 '12 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .