How To Run Meld on Mac OS X Yosemite Without Homebrew, MacPorts, or Think

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.

meld

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.

  1. Download and Install Yousseb fork for Mac https://yousseb.github.io/meld/.
  2. Create a meld file somewhere on my path, with code from comment by Levsa (pasted bellow) https://alexkras.com/how-to-run-meld-on-mac-os-x-yosemite-without-homebrew-macports-or-think/#comment-50195
  3. 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)
Code language: JavaScript (javascript)

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])
Code language: JavaScript (javascript)

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

60 thoughts on “How To Run Meld on Mac OS X Yosemite Without Homebrew, MacPorts, or Think”

  1. 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!!

  2. Meld can now be installed using: brew install homebrew/gui/meld

    I was wondering, how can I use meld as a git diff tool?

  3. 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.

      • 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.

    • 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.

  4. 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)

      • With errors fixed:

        #!/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)
        
        
          • … 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:

            ln -s /Applications/Meld.app/Contents/MacOS/Meld /usr/local/bin/meld
            

            For example, add it to your ~/.gitconfig file:

            [diff]
                tool = meld 
            
  5. 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?

  6. 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.

  7. 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.

  8. 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.

  9. 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!

  10. 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:

    • Paste the python script show a the bottom of this post into a text file and save it as “meld”. It can go on your desktop for now – my editor didn’t give me access to /usr/local/bin/ which was already in my path (I think that a default PATH entry. Check yours by typing “echo $PATH” into a terminal.)
    • Copy the file you saved onto the desktop into “/usr/local/bin/”. (You may need to show your hidden files for this, please Google that part).
    • You need to make you file executable, so open a terminal and navigate to /usr/local/bin/. Type
      “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”.

    #!/usr/bin/python
    
    import sys
    import os
    import subprocess
    
    MELDPATH = "/Applications/Meld.app"
    
    os.environ["LANG"] = "C"
    os.environ["LC_ALL"] = "C"
    
    subprocess.call(['open', '-W', '-a', MELDPATH, '--args'] + map( os.path.abspath, sys.argv[1:] ) )
    
    • 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.

  11. THANKS!!! I’ve been looking for such a solution for several months now! Youssef A. Abou-Kewik and you have changed my everyday life ๐Ÿ˜‰

  12. Thanks for the handy script! I updated it to handle more arguments so that it works for three-way merges:

    #!/usr/bin/python
    
    import sys
    import os
    import subprocess
    
    MELDPATH = "/Applications/Meld.app"
    
    subprocess.call( ['open', '-W', '-a',  MELDPATH, '--args'] + map( os.path.abspath, sys.argv[1:] ) )
    
    • 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

      #!/usr/bin/php
       &$val) {
          if (true === is_file($val) || true === is_dir($val)) {
              $val = escapeshellarg(realpath($val));
          }
      }
      
      $args = implode(' ', $argv);
      
      if ('--help' === $args) {
          passthru("{$meldPath}/Contents/MacOS/Meld-bin {$args}");
      } else {
          `open -F -n -W -a $meldPath --args $args`;
      }
      
  13. 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.

  14. 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.

  15. 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.

  16. 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

Comments are closed.