Meld on OS X
January 21st, 2009
So far the best diff viewer I have used is Meld, which up to now I could only use on my Ubuntu Linux partition. But now, thanks to Macports, I got it running on OS X. Yeah!
Update
I wrote this article about a year ago. As usual, technology advances, and this time it is in our favor. The hack for the .xinitrc is no longer necessary. On my machine I can install Meld straight from MacPorts and it runs straight away.
This took a bit of work, but I finally got Meld to run on OS X. The installation is very easy…just tell Macports to install Meld. In your terminal type:
sudo port install meld
Getting Meld to run on OS X was a bit trickier. When launching it normally I kept getting this error:
Xlib: extension “RANDR” missing on display “/tmp/launch-ODpC1P/:0″.
Traceback (most recent call last):
File “/opt/local/bin/meld”, line 109, in <module>
meldapp.main()
File “/opt/local/lib/meld/meldapp.py”, line 855, in main
app = MeldApp()
File “/opt/local/lib/meld/meldapp.py”, line 528, in __init__
self.prefs = MeldPreferences()
File “/opt/local/lib/meld/meldapp.py”, line 465, in __init__
prefs.Preferences.__init__(self, “/apps/meld”, self.defaults)
File “/opt/local/lib/meld/prefs.py”, line 91, in __init__
self._gconf.add_dir(rootkey, gconf.CLIENT_PRELOAD_NONE)
gobject.GError: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://www.gnome.org/projects/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-c1CO1rbT8i: No such file or directory)
This was fixed by launching Meld with sudo:
sudo /opt/local/bin/meld
However, this caused it to render without styling, ignoring the Clearlooks theme that every other app uses. While functional, it’s ugly.
A little reaserch showed that MacPorts recommended running Gnome on OS X with one of two configurations in the ~/.xinitrc file. Maybe if I used one of these it might fix the error? I created a new .xinitrc file and tried both methods. Using Apple’s dbus did not work. But using Metacity did.
Here is the ~/.xinitrc configuration worked for me:
# make sure X11 is MacPorts and /usr/local aware
PATH=$PATH:/opt/local/bin:/opt/local/sbin:/usr/local/bin
export PATH# make the freedesktop menu entries work
export XDG_DATA_DIRS=/opt/local/share
export XDG_DATA_HOME=/opt/local/share
export XDG_CONFIG_DIRS=/opt/local/etc/xdg# enable sound
export ESPEAKER=localhost# use GNOME’s window manager
exec metacity &# start GNOME
exec gnome-session
The above will use Gnome’s Metacity window manager (running inside X11). Visually it’s not quite as integrated with the OS X desktop as it would be by default. The only odd thing about Meld is that, when launched using the X11 terminal (and also the X11 Applications menu,) it reports that the pygtk library is old (it needs 2.6 and Macports only has 2.4.) But, when launched via the OS X terminal it will open in X11 just fine.
After setting up your ~/.xinitrc file launch X11. Here is what you type into the OS X terminal (not the X11 terminal) to launch Meld:
/opt/local/bin/meld
Here is a screenshot of Meld running on OS X via X11:
If this article was of interest you might want to try these related searches:

April 15th, 2009 at 4:14 am
I have exactly this error message but both hints aren’t working here ;(
July 14th, 2009 at 4:40 pm
[...] is, by far, the best diff viewer & editor that I have used. Earlier I posted about getting Meld up and running on OSX and overcoming a couple of issues. With the current version of MacPorts (1.7.1) and Meld 1.2, [...]
January 15th, 2010 at 1:48 pm
I tried your ~/.xinitrc, but now the X11 server crashes as soon as I launch it.
What dependencies (additional MacPorts packages) should I install to make this work? I tried installing metacity (which I did not have), but X11 still crashes as soon as I launch it.
Note that before I tried your .xinitrc, X11 would launch fine…
Thanks in advance!
-Blake
January 15th, 2010 at 1:52 pm
Oh forgot to say: OS X 10.6.2, MacBookPro Core 2 Duo.
-Blake
January 16th, 2010 at 8:34 am
The updated post (http://www.ubuntuproductivity.com/journal/macintosh/07/2009/meld-redux/) actually helped me to get this working.