alexkras.com

  • Home
  • Top Posts
  • Resume
  • Projects
  • YouTube
  • Boots to Bytes
  • About
  • Contact

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

February 28, 2015 by Alex Kras 60 Comments

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://www.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)

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

Filed Under: Tools

I work for Evernote and we are hiring!

Subscribe to this Blog via Email

New posts only. No other messages will be sent.

You can find me on LinkedIn, GitHub, Twitter or Facebook.

This blog is moving to techtldr.com

Comments

    Leave a Reply to Alex Kras Cancel reply

  1. Todd Fischer says

    October 30, 2018 at 9:02 am

    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

    Reply
  2. a7madgamal says

    March 21, 2017 at 7:48 am

    thanks a lot!

    Reply
  3. Saba says

    February 15, 2017 at 2:32 pm

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

    Reply
  4. Noopur Phalak says

    September 15, 2016 at 3:14 am

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

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

    Reply
    • Alex Kras says

      September 16, 2016 at 4:35 pm

      I have this added in my ~/.gitconfig file

      [diff]
          tool = meld 
      

      Then git difftool -d will lunch meld.

      Reply
  5. Youssef Abou-Kewik says

    April 22, 2016 at 5:46 pm

    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.

    Reply
  6. Youssef Abou-Kewik says

    February 21, 2016 at 10:06 am

    Alex, please add a link to the https://yousseb.github.io/meld/ page if you could.

    Reply
    • Alex Kras says

      February 22, 2016 at 5:13 pm

      Done, thanks for the link back!

      Reply
      • Youssef Abou-Kewik says

        February 23, 2016 at 7:40 pm

        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.

        Reply
  7. Rich Brown says

    February 18, 2016 at 5:38 pm

    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/

    Reply
    • Alex Kras says

      February 19, 2016 at 6:57 pm

      Thanks, I’ve added a link to the latest release with a comment.

      Reply
  8. Youssef Abou-Kewik says

    February 13, 2016 at 9:36 pm

    I just uploaded a new release to github. Please check and let me know if it still breaks.

    Reply
    • Alex Kras says

      February 19, 2016 at 6:59 pm

      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.

      Reply
  9. Jim Belton says

    February 4, 2016 at 8:57 pm

    On a new mac, I was able to install meld with brew using: brew install homebrew/x11/meld

    Reply
    • levsa says

      February 10, 2016 at 8:03 pm

      There is also a native build of meld for os x:

      https://github.com/yousseb/meld/releases/tag/osx-v1

      Reply
  10. Levsa says

    November 11, 2015 at 8:10 am

    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)

    Reply
    • Levsa says

      November 11, 2015 at 8:12 am

      Sorry about the formatting, the second line after else: is outside of the else block.

      Reply
      • Levsa says

        November 11, 2015 at 11:08 am

        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)
        
        
        Reply
        • Youssef Abou-Kewik says

          April 22, 2016 at 10:20 pm

          A slightly modified version of this is now part of the wrapper script in release osx-8. Thanks.

          Reply
          • coyotwill says

            April 26, 2017 at 12:33 pm

            … 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 
            
  11. Yoni says

    October 14, 2015 at 5:36 am

    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?

    Reply
    • Greg says

      October 14, 2015 at 7:07 pm

      Me too! No idea how to solve it.

      Reply
      • Gruntfuggly says

        October 15, 2015 at 1:49 pm

        Are you using the alpha version or the latest?

        Reply
        • Yoni says

          October 15, 2015 at 5:55 pm

          latest.

          Reply
          • Gruntfuggly says

            October 15, 2015 at 7:11 pm

            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.

          • Yoni says

            October 15, 2015 at 7:30 pm

            Thanks for the offer, but alpha turns out to do the same…

          • Gruntfuggly says

            October 15, 2015 at 7:34 pm

            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

          • Yoni says

            October 15, 2015 at 7:44 pm

            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!

      • Davi Lima says

        November 12, 2015 at 11:56 am

        +1 with LSOpenURLsWithRole() failed for the application /Applications/Meld.app with error -10810.

        Reply
  12. Gruntfuggly says

    September 11, 2015 at 1:27 pm

    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.

    Reply
    • Gruntfuggly says

      September 11, 2015 at 1:29 pm

      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.

      Reply
    • Gruntfuggly says

      September 11, 2015 at 1:43 pm

      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

      Reply
  13. Youssef A. Abou-Kewik says

    September 4, 2015 at 10:24 pm

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

    Reply
    • Alex says

      September 4, 2015 at 10:58 pm

      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.

      Reply
  14. William Cattey says

    August 8, 2015 at 4:44 am

    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.

    Reply
    • Alex says

      September 1, 2015 at 10:51 pm

      Try getting the older version. I think I might have used https://github.com/yousseb/meld/releases/tag/osx-v1

      Reply
      • William Cattey says

        September 13, 2015 at 3:13 am

        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

        Reply
  15. Grey says

    August 7, 2015 at 8:17 pm

    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!

    Reply
    • Grey says

      August 8, 2015 at 1:02 am

      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.

      Reply
      • Alex says

        September 1, 2015 at 10:51 pm

        Thank you, I think that is the build that I used.

        Reply
  16. Gavin says

    June 29, 2015 at 2:53 pm

    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:] ) )
    
    Reply
    • Gavin says

      June 29, 2015 at 4:27 pm

      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.

      Reply
      • Gavin says

        June 30, 2015 at 2:57 am

        Figured it out… I just had to use the absolute path /usr/local/bin/meld in SourceTree preferences.

        Reply
        • Mateen says

          September 5, 2015 at 3:01 pm

          Son of a gun, this is so helupfl!

          Reply
  17. Carmelo says

    June 23, 2015 at 7:12 pm

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

    Reply
  18. Jules says

    June 13, 2015 at 12:21 am

    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:] ) )
    
    Reply
    • Jonathan Daigle says

      September 29, 2015 at 7:02 pm

      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`;
      }
      
      Reply
  19. Danny says

    June 5, 2015 at 1:17 pm

    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.

    Reply
  20. Youssef A. Abou-Kewik says

    May 19, 2015 at 10:47 am

    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.

    Reply
    • Alex says

      June 16, 2015 at 6:54 pm

      Awesome, I’ll be on a lookout for that 🙂

      Reply
  21. Kumar Raja says

    May 17, 2015 at 7:21 am

    The fix for the Meld Error problem is the following link.

    http://stackoverflow.com/questions/11892957/meld-on-os-x-10-7-doesnt-work

    Reply
  22. Kumar Raja says

    April 30, 2015 at 2:37 pm

    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.

    Reply
  23. preston says

    April 2, 2015 at 6:07 am

    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

    Reply
    • Alex says

      May 3, 2015 at 5:11 pm

      Yes, I didn’t get to that part, but should be an easy fix.

      Reply
  24. lechee says

    March 25, 2015 at 2:26 am

    nice script for dmg meld

    Reply

Trackbacks

  1. 日常使用 Git 的 19 个建议 | 知了园 says:
    January 5, 2016 at 1:18 pm

    […] Meld […]

    Reply
  2. akras14/alexkras.com | GITROOM says:
    November 21, 2015 at 4:00 pm

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

    Reply
  3. 19 Tips For Everyday Git Use | phamduyphong says:
    September 16, 2015 at 4:18 am

    […] favorite diff-ing program is Meld. I fell in love with it during my Linux times, and I carry it with […]

    Reply
  4. 19 Tips For Everyday Git Use says:
    September 8, 2015 at 4:47 am

    […] favorite diff-ing program is Meld. I fell in love with it during my Linux times, and I carry it with […]

    Reply
  5. How To Run Meld on Mac OS X Yosemite Without Homebrew, MacPorts, or Think | The Winding Journal says:
    June 24, 2015 at 6:08 pm

    […] Source: How To Run Meld on Mac OS X Yosemite Without Homebrew, MacPorts, or Think […]

    Reply

Copyright © 2021 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in