gitmacosdiffmerge

Using DiffMerge on CodeAnywhere and Git - "Not Found" Message


I have installed DiffMerge on my Mac and configured git to use it per their instructions and it works well.

http://twobitlabs.com/2011/08/install-diffmerge-git-mac-os-x/#comment-140648

Hit return to start merge resolution tool (diffmerge):
/usr/lib/git-core/git-mergetool: 1: eval: diffmerge: not found
merge of app/Http/Controllers/WizardController.php failed

Any ideas? Is there a different config that’s needed or something….?

The configs that I ran are:

git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd 'diffmerge "$LOCAL" "$REMOTE"'
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'
git config --global mergetool.diffmerge.trustExitCode true

The command that I run (when there is a git conflict to resolve) is:

git mergetool

Thanks

Added Comments:

When I have an SSH terminal connected to a remote server, such as the CodeAnywhere server, and I run "git mergetool" it apparently then runs /usr/lib/git-core/git-mergetool which is not finding diffmerge on the remote system. I don't see where diffmerge actually installs anything on the remote at all.

This is the git config portion that relates to diffmerge:

diff.tool=diffmerge
difftool.diffmerge.cmd=diffmerge "$LOCAL" "$REMOTE"
merge.tool=diffmerge
mergetool.diffmerge.cmd=diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"
mergetool.diffmerge.trustexitcode=true

it appears that this is the actual command that git uses to run diffmerge:

mergetool.diffmerge.cmd=diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"

the file throwing the error is /usr/lib/git-core/git-mergetool which I traced to this line in that file which is apparently running the above command from the command line and isn't finding diffmerge on the remote machine cuz it isn't installed on the remote machine cuz it was installed on my local machine:

if ! run_merge_tool "$merge_tool" "$present"
   then
      echo "merge of $MERGED failed" 1>&2
      mv -- "$BACKUP" "$MERGED"

      if test "$merge_keep_temporaries" = "false"
      then
         cleanup_temp_files
      fi

      return 1
fi

It would seem that either there is something I missed installing on the remote or there is a configuration that I missed that tells it to "temp copy" the files to my local then run diffmerge on my local then return the remote files to the remote. I just don't see which was missed in this case.

Thanks

Thank you @nwinkler for the quick reply. If I understand your suggestion it is for running a term win on the local Mac as opposed to running a term win on a remote (running it on the Mac meaning that the diffmerge.sh etc will, by default, be available to the Mac's term win via the drive its running on as a term win) whereas, a remote term win won't have direct access to my local drive. Please correct me if I'm wrong.

I did run "which diffmerge" as you suggested and it doesn't find it at all (not installed on the remote).

I will look deeper into your suggestions and see if there is something to install on the remote and also try the "installer" is you suggested.

If I run it from a term win that is running from my local Mac it does work properly.

I agree it is that it's not finding diffmerge on the remote. I just don't see what is to be installed there....

Thanks, continuing research and trying out your suggestions further.


Solution

  • The problem seems to be that the diffmerge executable is not on your $PATH. If you type the following in your terminal, it should show you whether diffmerge can be found:

    which diffmerge
    

    If diffmerge was installed into your path, it should show something like this:

    $ which diffmerge
    /usr/local/bin/diffmerge
    

    If diffmerge was not installed, the output of the which diffmerge command will be empty.

    To fix, there seem to be two ways:

    1. According to http://twobitlabs.com/2011/08/install-diffmerge-git-mac-os-x, you need to download the Diffmerge installer not the DMG from http://www.sourcegear.com/diffmerge/downloads.php. The installer will apparently install the diffmerge.sh script so it can be used from the command line.
    2. Linking the script to a location on your path yourself. To do this, you first need to find the script - by default, it should be installed in /Applications/DiffMerge.app/Contents/Resources/diffmerge.sh. If it's there, you can link it to something like /usr/local/bin/diffmerge like this:

      sudo ln -s /Applications/DiffMerge.app/Contents/Resources/diffmerge.sh /usr/local/bin/diffmerge
      

      This will ask for your user's password (for sudo). Once you have symlinked the file, you need to make sure that /usr/local/bin is on your PATH. First try to run which diffmerge again to see if it works now. If it doesn't work, please ensure to add /usr/local/bin to your PATH variable.

      To do this, you can edit your user's ~/.bash_profile file (with any text editor of your choice). Add a line like the following:

      export PATH=$PATH:/usr/local/bin
      

      Once you have saved the file, open a new terminal window and try which diffmerge again.