Uploaded image for project: 'Sourcetree For Mac'
  1. Sourcetree For Mac
  2. SRCTREE-7737

"Mergetool path issue" when launching external merge tool

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Low Low
    • None
    • 4.1.3
    • Diff
    • Severity 3 - Minor

      https://community.atlassian.com/t5/Sourcetree-questions/quot-Mergetool-path-issue-quot-when-launching-external-merge/qaq-p/1781360

      OSX / Ver 4.1.3

      When I choose "Launch external merge tool" I get

      Mergetool path issue

      Current path:/Library/Developer/CommandLineTools

      Please set the command tool path in Xcode and Try again!

      I don't know what this means or how to fix

      External diff tool works fine

      I have Sourcetree 4.1.3

      I tried 

      sudo rm -rf /Library/Developer/CommandLineTools

       Sourcetree immediately prompted me to instal Xcode.  Which I did.

      Still get the error

      Reverting to Sourcetree 4.1.1  solved issue

            [SRCTREE-7737] "Mergetool path issue" when launching external merge tool

            David Becker added a comment - - edited

            Try setting SourceTree to allow it to modify your global git config and then to use system git (assuming you have one installed). It can be a bit tricky to get the syntax working right, depending on the tool. I also finally decided to create a helper shell script so that the .gitconfig could be simplified and then doing all the work in the helper script. The combination of all those things is what finally worked for me.

             

            Example:

            [diff]
                tool = sourcetree
            [difftool]
                prompt = false
            [difftool "sourcetree"]
                cmd = ~/bin/diffhelper \"$LOCAL\" \"$REMOTE\"
                path = [merge]
                tool = sourcetree
            [mergetool]
                prompt = false
                keepBackup = false
            [mergetool "sourcetree"]
                cmd = ~/bin/mergehelper \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
                trustExitCode = true 

            Unfortunately, posting image attachments here are hosed so I can't see exactly what you're running into. Good luck!

            David Becker added a comment - - edited Try setting SourceTree to allow it to modify your global git config and then to use system git (assuming you have one installed). It can be a bit tricky to get the syntax working right, depending on the tool. I also finally decided to create a helper shell script so that the .gitconfig could be simplified and then doing all the work in the helper script. The combination of all those things is what finally worked for me.   Example: [diff]     tool = sourcetree [difftool]     prompt = false [difftool "sourcetree" ]     cmd = ~/bin/diffhelper \ "$LOCAL\" \ "$REMOTE\"     path = [merge]     tool = sourcetree [mergetool]     prompt = false     keepBackup = false [mergetool "sourcetree" ]     cmd = ~/bin/mergehelper \ "$LOCAL\" \ "$REMOTE\" \ "$BASE\" \ "$MERGED\"     trustExitCode = true Unfortunately, posting image attachments here are hosed so I can't see exactly what you're running into. Good luck!

            Satish Jha added a comment -

            I am getting this error in SourceTree 4.2.1

            Satish Jha added a comment - I am getting this error in SourceTree 4.2.1

            David Becker added a comment - - edited

            I just moved to a new MacBook and my "could not find FileMerge utility" problem returned, so I dug a little deeper and figured something out. Which, granted, is a different problem than this original ticket. But since I mentioned it here and it's similar enough that others might land here, I also wanted to share my solution.

            Despite what's in my .gitconfig file, SourceTree stores its own merge/diff tool settings in com.torusknot.SourceTreeNotMAS.plist, which defaults to FileMerge, even when I have "allow Sourcetree to modify your global..." unchecked.

            The reason I got it working again in my prior comments is because, during my testing, I tried setting merge/diff tools the UI again, which updated them in the properties file.

            The fix is to set the tool using the UI. But you can't do that when the "allow global" setting is unchecked because the fields are grayed out. Either just give in and let Sourcetree modify your global config file, or make a backup first, enable global in the UI, set the merge/diff tools, uncheck it and restore your original config file.

            Once the tool is set to Custom in the main properties file, then __ it seems to properly use what's defined in the .gitconfig by shelling out to git difftool or git mergetool as appropriate.

            However, my custom tool scripts still weren't working, for reasons I don't fully understand. I could see the command being run in the Debug > Show Tasks Manager menu, but they would exit with a non-zero code. They ran perfectly from the terminal however. So I changed the setting from using the embedded git to the system git and it magically started working. Perhaps there's some sort of binary architecture compatibility issue with the embedded git and my external tools... IDK

            Hope this helps someone!

            David Becker added a comment - - edited I just moved to a new MacBook and my "could not find FileMerge utility" problem returned, so I dug a little deeper and figured something out. Which, granted, is a different problem than this original ticket. But since I mentioned it here and it's similar enough that others might land here, I also wanted to share my solution. Despite what's in my .gitconfig file, SourceTree stores its own merge/diff tool settings in com.torusknot.SourceTreeNotMAS.plist, which defaults to FileMerge, even when I have "allow Sourcetree to modify your global..." unchecked. The reason I got it working again in my prior comments is because, during my testing, I tried setting merge/diff tools the UI again, which updated them in the properties file. The fix is to set the tool using the UI. But you can't do that when the "allow global" setting is unchecked because the fields are grayed out. Either just give in and let Sourcetree modify your global config file, or make a backup first, enable global in the UI, set the merge/diff tools, uncheck it and restore your original config file. Once the tool is set to Custom in the main properties file,  then  __ it seems to properly use what's defined in the .gitconfig by shelling out to git difftool or git mergetool as appropriate. However, my custom tool scripts still weren't working, for reasons I don't fully understand. I could see the command being run in the Debug > Show Tasks Manager menu, but they would exit with a non-zero code. They ran perfectly from the terminal however. So I changed the setting from using the embedded git to the system git and it magically started working. Perhaps there's some sort of binary architecture compatibility issue with the embedded git and my external tools... IDK Hope this helps someone!

            All, The issue has been fixed in latest version 4.2.0. So requesting you to kindly upgrade the version to 4.2.0 and verify.

            Arati Mohanty added a comment - All, The issue has been fixed in latest version 4.2.0. So requesting you to kindly upgrade the version to 4.2.0 and verify.

            David Becker added a comment - - edited

            So I experimented some more, and it looks like the issue may be the escaped backslash to escape the space in the app name. If I change it to quote the app name instead, it works and the preferences window also shows my tool instead of FileMerge.

             

            I'm a happy camper!

            [diff]
              tool = intellij
            [difftool]
              prompt = false
            [difftool "intellij"]
                cmd = \"/Applications/IntelliJ IDEA.app/Contents/MacOS/idea\" diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
            [merge]
              tool = intellij
            [mergetool]
              prompt = false
              keepBackup = false
            [mergetool "intellij"]
                cmd = \"/Applications/IntelliJ IDEA.app/Contents/MacOS/idea\" merge $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\") $(cd $(dirname \"$BASE\") && pwd)/$(basename \"$BASE\") $(cd $(dirname \"$MERGED\") && pwd)/$(basename \"$MERGED\")
                trustExitCode = true
              

            David Becker added a comment - - edited So I experimented some more, and it looks like the issue may be the escaped backslash to escape the space in the app name. If I change it to quote the app name instead, it works and the preferences window also shows my tool instead of FileMerge.   I'm a happy camper! [diff]   tool = intellij [difftool]   prompt = false [difftool "intellij" ]     cmd = \ "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea\" diff $(cd $(dirname \ "$LOCAL\" ) && pwd)/$(basename \ "$LOCAL\" ) $(cd $(dirname \ "$REMOTE\" ) && pwd)/$(basename \ "$REMOTE\" ) [merge]   tool = intellij [mergetool]   prompt = false   keepBackup = false [mergetool "intellij" ]     cmd = \ "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea\" merge $(cd $(dirname \ "$LOCAL\" ) && pwd)/$(basename \ "$LOCAL\" ) $(cd $(dirname \ "$REMOTE\" ) && pwd)/$(basename \ "$REMOTE\" ) $(cd $(dirname \ "$BASE\" ) && pwd)/$(basename \ "$BASE\" ) $(cd $(dirname \ "$MERGED\" ) && pwd)/$(basename \ "$MERGED\" )     trustExitCode = true  

            I also just realized that's a different error message. So sorry for confusing the two. I'm not sure why SourceTree would use my .gitconfig for difftool but not mergetool. I will try to play with the config to see if I can resolve it.

            David Becker added a comment - I also just realized that's a  different error message. So sorry for confusing the two. I'm not sure why SourceTree would use my .gitconfig for difftool but not mergetool. I will try to play with the config to see if I can resolve it.

            Oh, I see why I couldn't reproduce it earlier. I did not have any merges to conduct and incorrectly assumed it would also affect difftool, but it does not. I just now had a merge to do and got "Could not find FileMerge utility. Current developer directory path: /Library/Developer/CommandLineTools. Please set the command tool path in Xcode and Try again!" So my original method of repeating it probably would have worked if I had tried a merge...

            The relevant section of my .gitconfig is:

             

            [diff]
              tool = intellij
            [difftool]
              prompt = false
            [difftool "intellij"]
              cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
            [merge]
              tool = intellij
            [mergetool]
              prompt = false
              keepBackup = false
            [mergetool "intellij"]
              cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea merge $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\") $(cd $(dirname \"$BASE\") && pwd)/$(basename \"$BASE\") $(cd $(dirname \"$MERGED\") && pwd)/$(basename \"$MERGED\")
              trustExitCode = true 

             

             

            David Becker added a comment - Oh, I see why I couldn't reproduce it earlier. I did not have any merges to conduct and incorrectly assumed it would also affect difftool, but it does not. I just now had a merge to do and got "Could not find FileMerge utility. Current developer directory path: /Library/Developer/CommandLineTools. Please set the command tool path in Xcode and Try again!" So my original method of repeating it probably would have worked if I had tried a merge... The relevant section of my .gitconfig is:   [diff]   tool = intellij [difftool]   prompt = false [difftool "intellij" ]   cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea diff $(cd $(dirname \ "$LOCAL\" ) && pwd)/$(basename \ "$LOCAL\" ) $(cd $(dirname \ "$REMOTE\" ) && pwd)/$(basename \ "$REMOTE\" ) [merge]   tool = intellij [mergetool]   prompt = false   keepBackup = false [mergetool "intellij" ]   cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea merge $(cd $(dirname \ "$LOCAL\" ) && pwd)/$(basename \ "$LOCAL\" ) $(cd $(dirname \ "$REMOTE\" ) && pwd)/$(basename \ "$REMOTE\" ) $(cd $(dirname \ "$BASE\" ) && pwd)/$(basename \ "$BASE\" ) $(cd $(dirname \ "$MERGED\" ) && pwd)/$(basename \ "$MERGED\" )   trustExitCode = true    

            David Becker added a comment - - edited

            @Raman

            While the SourceTree diff/merge settings window does indeed show FileMerge (but grayed out), my global ~/.gitconfig is configured to use IntelliJ as the diff/merge tools.

            After upgrading to 4.2.0 a few days ago and uninstalled the full Xcode and reinstalled the Xcode Command Line Tools and it was working. Then, yesterday, it stopped working again. At which point, I removed the command line tools and reinstalled the full Xcode to get it working again.

            I spent about an hour this morning removing the full Xcode and going back to the command line tools, and tried to get it to break again but could not. I tried rebooting, removing the Xcode preferences files, clearing ~/Library/Caches - but it is still working.

            I am getting a new MacBook next week, which I will be setting up 100% from scratch. I will report back then, or if it breaks again before that, and let you know how it went.

            If there's anything you want me to try on my current system, I'm happy to.

            David Becker added a comment - - edited @Raman While the SourceTree diff/merge settings window does indeed show FileMerge (but grayed out), my global ~/.gitconfig is configured to use IntelliJ as the diff/merge tools. After upgrading to 4.2.0 a few days ago and uninstalled the full Xcode and reinstalled the Xcode Command Line Tools and it was working. Then, yesterday, it stopped working again. At which point, I removed the command line tools and reinstalled the full Xcode to get it working again. I spent about an hour this morning removing the full Xcode and going back to the command line tools, and tried to get it to break again but could not. I tried rebooting, removing the Xcode preferences files, clearing ~/Library/Caches - but it is still working. I am getting a new MacBook next week, which I will be setting up 100% from scratch. I will report back then, or if it breaks again before that, and let you know how it went. If there's anything you want me to try on my current system, I'm happy to.

            Hi, e2b28b020815

            Thanks for contacting us. 

            Could you please clarify which merge tool is configured in Sourcetree preferences?

            It might happen, that you have Merge Tool: "FileMerge" utility configured in Sourcetree settings. It means, that Sourcetree will try to launch "FileMerge" utility when you click "Launch external merge tool".

            In case Xcode is not installed, Sourcetree will not be able to locate "FileMerge" binary, because it shipped as a part of Xcode (/Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge)

            Other words, to launch FileMerge utility, you need Xcode to be installed. But, other external merge tools (like DiffMerge, e.t.c) could be launched without installed Xcode now. Previously there was a bug, when using any of external merge tool constantly failed because of missing Xcode. 

            Small note: to use external merge tool you need this tool installed on your machine.

            Let me know, if you still have issues with external merge tool. In this case provide detail about merge tool configuration in Sourcetree settings. We will try to help you.

            Thanks.

            Raman Sidarakin (Inactive) added a comment - Hi, e2b28b020815 Thanks for contacting us.  Could you please clarify which merge tool is configured in Sourcetree preferences? It might happen, that you have Merge Tool: "FileMerge" utility configured in Sourcetree settings. It means, that Sourcetree will try to launch "FileMerge" utility when you click "Launch external merge tool". In case Xcode is not installed, Sourcetree will not be able to locate "FileMerge" binary, because it shipped as a part of Xcode (/Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge) Other words, to launch FileMerge utility, you need Xcode to be installed. But, other external merge tools (like DiffMerge, e.t.c) could be launched without installed Xcode now. Previously there was a bug, when using any of external merge tool constantly failed because of missing Xcode.  Small note: to use external merge tool you need this tool installed on your machine. Let me know, if you still have issues with external merge tool. In this case provide detail about merge tool configuration in Sourcetree settings. We will try to help you. Thanks.

            Not fixed for me. I've found that if you had XCode installed and then removed it in favor of the CLI tools, it works temporarily but seems to break again later (maybe after a system reboot)...

            David Becker added a comment - Not fixed for me. I've found that if you had XCode installed and then removed it in favor of the CLI tools, it works temporarily but seems to break again later (maybe after a system reboot)...

              Unassigned Unassigned
              502df7580869 Bradley Kent
              Affected customers:
              51 This affects my team
              Watchers:
              53 Start watching this issue

                Created:
                Updated:
                Resolved: