Getting “flags:FATAL unable to determine getopt version” while trying to do git flow init

I am preparing for a presentation on git flow for the Orlando PHP Users Group. I don’t use git flow on my laptop, so I thought I should set it up since the wireless is kind of spotty at our meeting place.

Installation was simple enough, however when trying to init I was receiving an error about getopt.

JC-PowerBook17:gitflow jcongdon$ git flow init
/opt/local/bin/gitflow-shFlags: line 119: 70405 Trace/BPT trap getopt > /dev/null 2>&1
flags:FATAL unable to determine getopt version

By running getopt directly I found this

JC-PowerBook17:gitflow jcongdon$ getopt
dyld: Library not loaded: /opt/local/lib/libintl.8.dylib
Referenced from: /opt/local/bin/getopt
Reason: no suitable image found. Did find:
/opt/local/lib/libintl.8.dylib: mach-o, but wrong architecture
Trace/BPT trap

Basically it looks like my libintl.8.dylib is not correct. I ran the following:

JC-PowerBook17:gitflow jcongdon$ otool -L /opt/local/lib/libintl.8.dylib
/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.42.0)

I see that this is version 10.1.0. I then ran:

JC-PowerBook17:gitflow jcongdon$ otool -L /opt/local/bin/getopt
/opt/local/lib/libintl.8.dylib (compatibility version 9.0.0, current version 9.2.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)

WTF?!?!? getopt is looking for 9.2.0? It turns out that I tried doing something along time ago that messed up my libraries. Luckily I made a copy of them for some unknown reason. I just copied my backup version over the old one and it works. I probably broke something else in the meantime though. :’-(