Monday, March 16, 2009

Mercurial and Terminal.app on Mac OS X

Get a latest Mercurial from here and... bang!


Traceback (most recent call last):
File "/usr/local/bin/hg", line 25, in
mercurial.util.set_binary(fp)
File "/Library/Python/2.5/site-packages/mercurial/demandimport.py", line 75, in __getattribute__
self._load()
File "/Library/Python/2.5/site-packages/mercurial/demandimport.py", line 47, in _load
mod = _origimport(head, globals, locals)
File "/Library/Python/2.5/site-packages/mercurial/util.py", line 93, in
_encoding = locale.getlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 460, in getlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 373, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Yes, because it is Terminal.app, it is not XTerm. Apple had a years to add Spotlight, but had zero time to fix a bug, that is for years around: bad locale handling. To fix the bones, add into .profile this explicitly:


export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

...or foo_BAR about your other locale.

1 comment:

bubenkoff said...

thanks man - helped me