I love Meld. It’s is my favorite diff tool, and one of the tools I missed the most when I switched over to Mac from Linux.
Except, you can run Meld on Mac too. The easiest way is using Homebrew, via brew install meld
. If you don’t have Homebrew on your Mac yet, it will only take a minute to install via one simple command, and you will probably end up installing it at some point anyway.
Update 02/15/2019
Here is what I had to do to get it working in 2020.
- Download and Install Yousseb fork for Mac https://yousseb.github.io/meld/.
- Create a meld file somewhere on my path, with code from comment by Levsa (pasted bellow) https://www.alexkras.com/how-to-run-meld-on-mac-os-x-yosemite-without-homebrew-macports-or-think/#comment-50195
- Make sure the file is still executable
sudo chmod a+x ~/bin/meld
Improved Script from Levsa:
#!/usr/bin/python
import sys
import os
import subprocess
MELDPATH = "/Applications/Meld.app"
userArgs = []
for arg in sys.argv[1:]:
if arg.startswith('--output'):
filename = arg.split('=')[1]
newArg = '--output=' + os.path.abspath(filename)
elif arg.startswith('-'):
newArg = arg
else:
newArg = os.path.abspath(arg)
userArgs.append(newArg)
argsArray = ['open', '-W', '-a', MELDPATH, '--args'] + userArgs
print argsArray
p = subprocess.call(argsArray)
Old Post:
Note: `brew install meld` will probably fail, but the error will show you the proper command to run. In February of 2016 for me that command was `brew install homebrew/gui/meld`, some people report that `brew install homebrew/x11/meld` worked for them. Just read the outputted message carefully. It will probably have to pull in a lot of dependencies so it might take a while, but it should work.
For some reason Homebrew did not work for me on my new Mac back in February of 2015, so I had to look for other options (hence the “Without Homebrew, MacPorts, or Think” part in the original title of this article).
After some intense Googling, I came across this AWESOME fork of Meld. It is Meld packaged with all of the dependencies into a regular .dmg. Pleae make sure to visit the official project page – Meld for OSX.
Note: I am linking to release tagged osx-v1, there have been other releases since then. Some of them did not work for all users, but the latest release (OSX – 3.15.2) suppose to work. You might have to try a few release to find the one that works for you. The author of of that package posts his updates in the comments sometimes, so be on a lookout for that. If all fails I recommend using version osx-v1, since it seems to work for most users.
As I said earlier, Meld.dmg “just worked” for me, except that it didn’t work in the command line, and that is where I need it the most.
I wrote the following script (in python since you already need it to run meld) and placed it in ~/bin
folder (making sure to add ~/bin to my PATH, see bellow).
Note: There is a cleaner version posted in the comments that should work with 3 arguments, allowing you to use meld as a merge tool. I have not tested it, but it looks like it should work, and it might be worth your time to try it first.
#!/usr/bin/python import sys import os import subprocess if len(sys.argv) > 1: left = os.path.abspath(sys.argv[1]); else: left = "" if len(sys.argv) > 2: right = os.path.abspath(sys.argv[2]); else: right = "" MELDPATH = "/Applications/Meld.app" p = subprocess.call(['open', '-W', '-a', MELDPATH, '--args', left, right])
I then added that folder to my PATH via export PATH=~/bin:$PATH
entry in my .bashrc
file, to make sure that meld command got picked up in my terminal. You can reload your bash config via . ~/.bashrc
or just restart the terminal. Type in meld
and it should work.
I’ve been using it for a few weeks many months now, and yet to run into any problems. So there you have it, a working Meld on Mac OS X Yosemite, without having to use any 3rd party tools.
- Updated February 13, 2016
- Updated homebrew instructions
- Updated Meld fork reference instructions
I had sporadic behavior on OS X 10.14 Mojave and found these commands fixed my problem.
rm -rf ~/.local/share/meld
rm -f ~/Library/Preferences/org.gnome.meld.plist
rm -rf “~/Library/Saved Application State/org.gnome.meld.savedState/”
From issue #70 https://github.com/yousseb/meld/issues/70
thanks a lot!
Quite a rookie problem but I spent hours thinking why running
meld
doesn’t run it! daaa, I need to name the script file meld for it work!!Meld can now be installed using: brew install homebrew/gui/meld
I was wondering, how can I use meld as a git diff tool?
I have this added in my
~/.gitconfig
fileThen
git difftool -d
will lunch meld.Guys, whenever you could, please test this release:
https://github.com/yousseb/meld/releases/tag/osx-7
It shouldn’t require a wrapper script any longer. I haven’t had the time to 100% clean the wrapper script, but it seems functional and is based on what you guys have suggested here. You can find the script in /Applications/Meld.app/Contents/MacOS/Meld after you have installed Meld. If you have suggestions or fixes that you’d like to add to it, I’d love to hear from you.
Alex, please add a link to the https://yousseb.github.io/meld/ page if you could.
Done, thanks for the link back!
No, man. Thank you for maintaining this page. It’s been awesome! The feedback on this page has been amazing and I would have honestly stopped at 1.8 (it pretty much fit the bill for what I needed) if it wasn’t for the feedback on your page.
As of mid-February, yousseb has released a 3.15.2 version as a .dmg. Installs and runs just fine. Get the latest at: https://github.com/yousseb/meld/releases/
Thanks, I’ve added a link to the latest release with a comment.
I just uploaded a new release to github. Please check and let me know if it still breaks.
Thanks, I am a bit short on time to re-install it and try it out right now, but I’ve added a link in the note for now, and will try to test it later.
I’ve also change the order of comments to make sure that this shows up first.
On a new mac, I was able to install meld with brew using: brew install homebrew/x11/meld
There is also a native build of meld for os x:
https://github.com/yousseb/meld/releases/tag/osx-v1
I made a version of the mapping, but one that detects options:
#!/usr/bin/python
import sys
import os
import subprocess
MELDPATH = “/Applications/Meld.app”
userArgs = []
for arg in sys.argv[1:]:
if arg.startswith(‘–output’):
filename = arg.split(‘=’)[1]
newArg = ‘–output=’ + filename
elif arg.startswith(‘-‘):
newArg = arg
else:
newArg = os.path.abspath(arg)
userArgs.append(newArg)
argsArray = [‘open’, ‘-W’, ‘-a’, MELDPATH, ‘–args’] + userArgs
print argsArray
p = subprocess.call(argsArray)
Sorry about the formatting, the second line after else: is outside of the else block.
With errors fixed:
A slightly modified version of this is now part of the wrapper script in release osx-8. Thanks.
… which means you can simply create a symlink in usr/local/bin and use it super easily from the command-line, as well as a diff tool:
For example, add it to your
~/.gitconfig
file:I am getting the following error after doing as the post says:
LSOpenURLsWithRole() failed for the application /Applications/Meld.app with error -10810
Any ideas?
Me too! No idea how to solve it.
Are you using the alpha version or the latest?
latest.
The only version I could get to work was the alpha version. Not sure what the later versions fix or add, but the alpha version does everything I need it to do.
Thanks for the offer, but alpha turns out to do the same…
Sorry – my mistake, it’s not the alpha build that works, but the first build here:
https://github.com/yousseb/meld/releases/tag/osx-v1
Now it works!
To be precise, now I had the meld error problem, but fixed it as described in the link above.
Thanks a lot!
+1 with LSOpenURLsWithRole() failed for the application /Applications/Meld.app with error -10810.
I couldn’t get this to work with any but the initial alpha version of Meld.
I thought you might like to know there is a simpler way to invoke Meld via mergetool, without the need for any extra scripts:
[mergetool “meld”]
cmd = open -W -a Meld –args –diff `pwd`/$BASE `pwd`/$LOCAL –diff `pwd`/$BASE `pwd`/$REMOTE –auto-merge `pwd`/$LOCAL `pwd`/$BASE `pwd`/$REMOTE –output `pwd`/$MERGED
Note: the pwd should be in backticks to insert the full path. For some reason, open seems to use the context of the application rather than where you open it from.
Wow – the backticks didn’t even show up! I wasn’t expecting that. They should look like ‘pwd’ but with backticks, if you know what I mean.
In fact scratch that, it’s easier to just do:
cmd = open -W -a Meld –args –auto-merge $PWD/$LOCAL $PWD/$BASE $PWD/$REMOTE –output $PWD/$MERGED
Ops – didn’t check this thread in a while. I also didn’t notice that you couldn’t report issues on my fork in github.
I’ll see how to enable that and get back to you guys in here.. I did test on multiple Macs with Yosemite, but I’d really like this fork to be useful. I hated meld on macports and it’s about the best diff/merge tool I ever used. I’d like to spread it around.. 🙂
Thanks Youssef,
Are you on Twitter? I would love to put your handle in the main post. I can also link to a website if you want.
Let me know.
Alex.
I just tried the .dmg version, but alas it does not run for me.
I’d love to try and debug the beta, but there doesn’t seem to be a way to make contact with Yousef.
I’d actually gotten the MacPorts version of meld running under Quartz without X11 on my Mavericks system, but that was a year ago. It looks like I’m gonna have to refresh my understanding of the lore.
Try getting the older version. I think I might have used https://github.com/yousseb/meld/releases/tag/osx-v1
Yes, the osx-v1 version does work.
The later versions just crash.
The error I get with osx-v3 is:
9/12/15 11:09:27.898 PM com.apple.launchd.peruser.501[228]: (org.gnome.meld.332320[38819]) Exited with code: 1
Nice find. I just recently moved to Mac, and Meld has absolute favorite diff tool.
I got a bit of trouble running the Meld app, though. Perhaps someone can give me a clue?
Meld won’t run and if I try running it from terminal, I see the following.
Couldn’t bind the translation domain. Some translations won’t work.
‘module’ object has no attribute ‘bind_textdomain_codeset’
Cannot import: GTK+
cannot import name Gtk
Thanks!
I should mention that the error is from OSX – 3.13.4 (beta build).
I tried the first OSX build just now (Meld 1.8.6), and that version works on my Mac.
Thank you, I think that is the build that I used.
I am not a python guy and only a recent mac guy, so I’d like to add to the above comments with the following points:
“chmod +x meld”
This should now work if you’re more of a noob like me. Python script that worked for me for both diff and merge, with the Meld Error fix is as follows. Please check the single and double quotes have not been botched by your text editor, check you have a double hyphen before “args”.
With the steps outlined above, Meld still only runs from SourceTree when I run SourceTree using the command line tool (stree) or by double-clicking the executable from the SourceTree package contents. I guess this is a permissions thing but I haven’t figured out why yet.
Figured it out… I just had to use the absolute path /usr/local/bin/meld in SourceTree preferences.
Son of a gun, this is so helupfl!
THANKS!!! I’ve been looking for such a solution for several months now! Youssef A. Abou-Kewik and you have changed my everyday life 😉
Thanks for the handy script! I updated it to handle more arguments so that it works for three-way merges:
Still does not work with some of the arguments meld can take like -L. or –help
Since i am not very fluent in python, i wrote mine in php
Hi Alex.
I download and configure the python bin file with success.
However when I try to run “meld” in the terminal I got a message “meld error” and application cannot open.
Hi, Alex. I’m the author of the github repo for Meld for OSX. Thanks for the nice words about the DMG build. I’ll try to make sure that meld runs through the command line on Mac in the next builds.
Have a good day.
Awesome, I’ll be on a lookout for that 🙂
The fix for the Meld Error problem is the following link.
http://stackoverflow.com/questions/11892957/meld-on-os-x-10-7-doesnt-work
This method is not working for me. I have tried it. It is throwing “Meld Error” open console/Terminate options. I have put the script in ~/bin dir. But still not sure. If u know fix please let me know.
Great find. Have looked for this for a while. I hacked the python script so it would work
with three files which is needed for merges in some source control packages to resolve conflicts.
Thanks,
-preston
Yes, I didn’t get to that part, but should be an easy fix.
nice script for dmg meld