FileMerge quits immediately after launching from SourceTree
Asked Answered
K

7

68

I regularly use Atlassian SourceTree (on Mac OS X) to launch FileMerge to resolve git merge conflicts. Out of the blue it has stopped working: when I right click and select Resolve Conflicts > Launch External Merge Tool, FileMerge launches, creates its intermediate files, then immediately exits. SourceTree interprets that as the merge process being complete.

What's the issue and how can I debug/fix it?

I note that a previous question 'SourceTree filemerge quits immediately and creates 4 files. How to fix it?' does not address this particular scenario (for one, it says FileMerge quits in the title, but in the body it says FileMerge displays /dev/null as one of the panels. Additionally, my merge conflict is not due to a removed file.)

Korikorie answered 23/9, 2015 at 0:14 Comment(1)
try this on terminal and use SourceTree : "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"Bewitch
U
183

To diagnose the problem, I ran opendiff from the Terminal. I received the following error:

xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

To solve:

  1. Open Xcode > Preferences > Locations
  2. Click on the drop-down box beside Command Line Tools and select your current Xcode version. (This was empty for me because I had recently installed Xcode on a new Mac.)

Command Line Tools

  1. Run opendiff in Terminal again, and the above error should no longer appear.

Now FileMerge will open correctly from SourceTree when you click Launch External Merge Tool.

Unruffled answered 5/1, 2017 at 17:9 Comment(6)
Thanks, fixed the issue, It is still SourceTree's bug not to alert on the error, and to consider the file "merged" though. However, this Mac application is so bad - I don't even care to notify them about their bugs anymore. Nothing to expect there.Transform
@MottiShneor I agree that SourceTree should improve their user experience. This bug is already filed so feel free to up-vote it.Unruffled
Thanks for the answer, it fixed my problem. It is unfortunate that SourceTree doesn't show any error dialog about this.Domitiladomonic
This fixes opendiff ( FileMerge ) not opening from SourceTree when selecting Resolve Merge Conflicts using External ToolScrotum
Fixed mine too for Tower. My Xcode was not recently installed, but gets updated automatically and one of those updates left the Command Line Tools location empty. Had to quit both apps and then re-start Xcode and Tower (in that order).Cork
It needs full xcode not just command line tools, or you can use older version of sourcetree which works 4.1.2Disinfest
S
22

For me, SourceTree didn't even launch FileMerge. When clicking Launch External Merge Tool nothing happened.

Moreover, running opendiff in Terminal worked as expected:

$ opendiff
opendiff[64176:5561154] too few arguments
opendiff[64176:5561154] usage: opendiff file1 file2 [-ancestor ancestorFile] [-merge mergeFile]

What helped me was manually configuring SourceTree to use FileMerge via the opendiff command with the following arguments: $LOCAL $REMOTE -ancestor $BASE -merge $MERGED

SourceTree manually configure to use opendiff

This way, SourceTree opens FileMerge as expected.

Sack answered 18/7, 2017 at 12:25 Comment(4)
Same here, but i don't know why it didn't work when just set to file mergeDefiniendum
yup, this did it for me, finally, after a lot of trial and errors. If I just select diffmerge from the dropdown, it fails to launch external diff tool (ST shows a window saying that will need to close diff tool to return, but that window closes imediately). diffmerge was set correcly in .gitconfig, worked fine with "git mergetool" command, but I guess ST was ignoring that altogetherBaten
I've had perpetual issues with this for many years. It has always been resolved by ensuring I agreed to the license agreement for xcode developer tools...until now. Your solution seems to do the trick this time. However, it did not work at first; I had to nuke my ~/.gitconfig file for some reason.Steiger
Update: It seems that the "FileMerge" selection in ST now works again. Perhaps I just needed to nuke my config file.Steiger
C
21

This helped: https://gist.github.com/kylefox/4512777

Tell system when Xcode utilities live:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Set "opendiff" as the default mergetool globally:

git config --global merge.tool opendiff

Caespitose answered 7/9, 2018 at 11:0 Comment(2)
That was it! the git config --global, thanks a lot!Problem
xcode-select command is what solved it for me on Apple silicon. I had a location set in Xcode preferences, but it didn't seem to help.Hissing
K
8

If Xcode has recently updated itself, you may need to agree to the new license terms. If you have not agreed to the license terms, FileMerge (when launched from SourceTree) will quit immediately.

To check for this, open a shell and run as your usual user:

$ opendiff

If the license is the problem, it will tell you. To agree to the new license terms, you'll need to run open diff using sudo:

$ sudo opendiff

After agreeing to the license terms, you can now retry launching FileMerge from SourceTree using Resolve Conflicts > Launch External Merge Tool. FileMerge should launch and behave normally.

Korikorie answered 23/9, 2015 at 0:14 Comment(2)
It says opendiff xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instanceBottomry
@Greg Kopff's thanks, your solution worked with me! :) In my case SourceTree was not openning FileMerge. I did update Xcode to 10.2.1 recently but I was using a previous active developer directory (see "xcode-select" terminal command) for still compiling some projects with Xcode 10.1 compiler. After setting the correct active developer directory again, "opendiff" runned ok and SourceTree was able again to open FileMerge.Cootie
W
6

This also works to resolve the message "xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance":

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Weatherbound answered 7/9, 2017 at 10:31 Comment(2)
i.e., make sure your xcode select is actually pointed at the /Contents/Developer subdir of an actual instance of Xcode. Helpful, thanksAnaplastic
My instance does not have such a directory, any tips?Hesperus
D
2

Tick Allow Sourcetree to modify your global... solves the issue for me source tree preference

Demonstrative answered 5/3, 2022 at 8:48 Comment(1)
This was useful for me to fix the "visual diff tool" and "merge tool" options from being disabled. Check this box, change your tool, run a merge then uncheck this box (if you want to disable it)Houseless
A
0

I have encountered this problem and solved it with the answer here
So this time, when I had it again, I thought the same issue happened...

And after trying for almost an hour, I've realized that the Diffmerge (or any external diff tool) did not open because there was no file in the current branch to merge.

This can happen when you do Cherry Pick where the commits can be jumpy. Added this answer to remind people who are going to have the same issue.

Asclepiadaceous answered 24/8, 2021 at 8:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.