Friday, June 19, 2009

MacPorts registry error on upgrading gettext

MacPorts 1.7.0. I just ran:

sudo port upgrade outdated

and ran into the following problem:

---> Deactivating gettext @0.17_3
>> Error: Deactivating gettext 0.17_3 failed:
>> Error: Unable to upgrade port: dyld: Library not loaded:
>> /opt/local/lib/libintl.8.dylib
>> Referenced from: /opt/local/bin/ln
>> Reason: image not found

The same error occurs when I run ln, which is the GNU version /opt/local/bin/ln in my case. Native BSD versions like /bin/ln are unaffected.

The problem appears to be a port error caused by the port implementation shelling out to utilities like rm and ln without full paths, and getting GNU versions, since I have installed coreutils +with_default_names. Here's the fix. Edit the file /opt/local/etc/macports/macports.conf and set the MacPorts registry path to have BSD utils ahead of GNU utils:

binpath /bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin:/usr/X11R6/bin


Now you should be able to deactivate the old gettext, activate the new one, fix your coreutils, and complete the update:

sudo port deactivate gettext
sudo port activate gettext
sudo vi /opt/local/etc/macports/macports.conf ## return binpath to previous value
sudo port uninstall coreutils +with_default_names
sudo port install coreutils


Of course, now your coreutils are installed in /opt/local/bin with names like gls, grm, etc. On the whole, this appears to be the safer option. In cases where you really want to use the GNU version, something like this in your shell init file should do the trick:

case $(uname) in
Darwin)
if [ -x "$(which gdircolors)" ] ; then
eval `gdircolors ~/.dir_colors`
fi
if [ -x "$(which gls)" ] ; then
alias ls='gls --color=tty'
else
alias ls='ls -G'
fi
;;
Linux)
if [ -x "$(which dircolors)" ] ; then
eval `dircolors ~/.dir_colors`
fi
alias ls='ls --color=tty'
;;
esac

No comments:

Post a Comment