7

I've tried setting meld as my mergetool to use with git doing:

git config --global merge.tool meld
git config --global mergetool.meld.path c:/Progra~2/meld/bin/meld

As outlined in answers to questions like:

How to set Meld as git mergetool

I used to have this working on my old work machine but now on my new machine where I have Python3 installed instead of 2.7 I am getting the following error whenever I try git mergetool:

C:/Program Files/Git/mingw64/libexec/git-core/mergetools/meld: c:/Progra~2/Meld/bin/meld: C:/msys64/MINGW32/bin/python3.exe: bad interpreter: No such file or directory

Any ideas what extra steps I need to make to get this to work with Python3?

EDIT: I have tried pointing directly to Meld.exe too but that causes the following crash:

enter image description here

3

1 Answer 1

8
+200

The .../bin/meld script is mostly there for reference. You should set

git config mergetool.meld.path "C:/Program Files (x86)/Meld/Meld.exe"

You don't need to use Progra~2 notation unless you really want to for some reason.

The only issue that I am having is that it is not properly picking up the installed dependency extensions in C:/Program Files (x86)/Meld/lib. You need to add C:/Program Files (x86)/Meld/lib to your PATH environment variable, either with SET PATH=C:/Program Files (x86)/Meld/lib;%PATH%, or through the "Edit Environment Variables for your account" somewhere in control panel/start menu.

Alternative Approach

If you open C:\Program Files (x86)\Meld\bin\meld in a text editor, you will see that it is a shell script that is intended to be run in python3 (called from C:\Program Files\Git\bin\sh.exe most likely).

The first line of meld reads:

#!C:/msys64/MINGW32/bin/python3.exe

This issue does not pop up when using Meld.exe because it does not use the script through a python interpreter.

It is unlikely that the python interpreter is installed at that location on your machine. Instead, you can replace the shebang line to point to an existing interpreter. For example, on my machine, meld starts with:

#!C:/Users/MadPhysicist/AppData/Local/Continuum/anaconda3/python.exe

This still won't be enough for the script to find the meld package and all the installed GTK, cairo, etc. DLLs, so you have to tweak both the python and system paths. Insert the following before the line import meld # noqua: E402 (line ~78):

os.environ['PATH'] = os.pathsep.join((melddir, os.path.join(melddir, 'lib'), os.environ['PATH']))
sys.path[0:0] = [os.path.join(melddir, 'lib/python3.7/site-packages')]

I was not ever able to get the first line to set up Cairo, GTK, etc. correctly for meld. You can, however, skip the first line and just install the packages using conda or pip. You will still need to insert the meld package into sys.path.

Keep in mind that meld is compiled in 32 bits, as evidenced by the x86 in the install folder. You can only run it with a 32-bit python interpreter if you use the included DLLs, which may require additional installation. You do not need a 32-bit interpreter if your environment contains all the necessary packages already.

7
  • Thanks for the help! That has gotten me one step further. Now getting the following error: ' File "c:/Progra~2/meld/bin/meld", line 79, in <module> import meld.conf # noqa: E402 ModuleNotFoundError: No module named 'meld''
    – Plog
    Commented Sep 27, 2019 at 15:20
  • Just saw your edit. I did actually try that originally, figured it wasn't meant to work due to the error I got. I've added it to my original question.
    – Plog
    Commented Sep 27, 2019 at 15:27
  • @Plog. I got meld to show up. Turns out it's a weird path thing. Not sure why it's happening. Most likely, you had PyGtk, PyCairo, PyGObject, etc. installed in your Python 2.7 environment. Commented Sep 27, 2019 at 19:47
  • @Plog. I wouldn't select this just yet. I'm going to look at the source of meld.exe, which I think should just be setting up the script's environment. Might get a PR out of this, or at least a bug report. Commented Sep 27, 2019 at 22:47
  • Wow super appreciate all the work you put into this! I'm a little confused though. Adding that folder to the PATH variable hasn't resolved the issue for me. Am I supposed to install the 32 bit interpreter too?
    – Plog
    Commented Sep 30, 2019 at 8:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.