git diff with opendiff gives "Couldn't launch FileMerge" error - xcode

I have git configured to use ~/bin/opendiff-git.sh as my external diff tool. That script looks like this:
opendiff $2 $5
When I try and do a git diff from the command line, I get this message:
2011-02-18 13:58:55.532 opendiff[27959:60f] exception raised trying to run FileMerge: launch path not accessible
2011-02-18 13:58:55.535 opendiff[27959:60f] Couldn't launch FileMerge
external diff died, stopping at source/some_file.m.
What's going on? This has worked for many months, but stopped working recently.

So AFTER I deleted the beta developer folder to try and solve this (couldn't get the fix to work with merge tool) I stumbled upon this in the command line:
Error: No developer directory found at /Developer Beta. Run /usr/bin/xcode-select to update the developer directory path.
Turns out you can set the developer path you need it to use:
Usage: xcode-select -print-path
or: xcode-select -switch <xcode_folder_path>
or: xcode-select -version
Arguments:
-print-path Prints the path of the current Xcode folder
-switch <xcode_folder_path> Sets the path for the current Xcode folder
-version
Looks like installing the beta had automatically set that path to beta. To fix it, run this:
sudo /usr/bin/xcode-select -switch /Developer
That fixed it for me.
Update
Ying's comment below was important enough to include in the answer. From Xcode 4.3 on, the location of the folder has changed to inside the application package:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer/

If you have two SDKs installed, and the latest (presumably beta) version doesn't have the System Tools installed, some tools like opendiff can break. You can only have one set of System Tools installed at a time, so you have to choose which SDK/installation has it. I fixed this problem by using the path of opendiff that is in the Developer folder that had the system tools installed.
In my case, I have the following Xcode installations:
Current stable release (with System Tools installed)
/Developer
Latest beta (without System Tools installed)
/Developer (iOS SDK XXX beta)
My ~/bin/opendiff-git.sh script now looks like this:
"/Developer/usr/bin/opendiff" $2 $5

first the reason is xcode's installation path modified since 4.3, so must reselect xcode path
full guide is in below link:
http://useyourloaf.com/blog/2012/2/17/updating-to-xcode-43.html

Related

How to continue using Git on mac after uninstalling Xcode (with Android Studio)?

I have installed Git on my Mac. When I do a "whereis" in my terminal the route is:
/usr/bin/git
I use Android Studio and the GitHub desktop client and had no problems so far.
Previously I had installed Xcode, but I uninstalled it a week ago. Since then, Android Studio does not detect Git, I get the following error:
xcrun: error: active developer path
("/Volumes/Vega/Applications/Xcode.app/Contents/Developer") does not
exist, use xcode-select --switch path/to/Xcode.app to specify the
Xcode that you wish to use for command line developer tools (or see
man xcode-select)
Android Studio shows the same executable path to Git
indicating the terminal (/usr/bin/git), but when I click on the "test" button it displays the same error.
I do not handle very well Git from the terminal, always use the desktop client.
What do I have to do to continue using Git on my Android studio (or anywhere) now that I uninstalled Xcode?
I searched for information but I can not fix it.
If commands sudo xcode-select --reset and xcode-select --install does not work for you and you dont want to install xcode then just reinstall git manually via brew:
brew reinstall git
And open new terminal session
Worked for me
sudo xcode-select --reset
Will reset your paths to the defaults if the command line tools are already installed.
You should install the Xcode command line tools at the very least. If you're not a registered Apple Developer, however, I'm not sure how to get hold of them if Xcode is not installed. If you are a registered Apple Developer, you can get them from the Apple Developer Download site. It' probably best to re-install Xcode and you will get them as a system update.
That will give you a minimal development environment, and if you need additional tools/libraries you can build them via Macports with the command line tools installed.
Try this :
xcode-select --install

How can I find out if I have Xcode commandline tools installed?

I need to use gdb.
ps-MacBook-Air:AcoustoExport pi$ gdb
-bash: gdb: command not found
ps-MacBook-Air:AcoustoExport pi$ sudo find / -iname "*gdb*"
Password:
/usr/local/share/gdb
/usr/local/Cellar/isl/0.12.1/share/gdb
:
and:
ps-MacBook-Air:AcoustoExport pi$ ls -la /usr/local/share/gdb
lrwxr-xr-x 1 pi admin 30 14 Jan 22:01 gdb -> ../Cellar/isl/0.12.1/share/gdb
Not quite sure what to make this, clearly it is something installed by homebrew. I don't know why it's there, I don't know whether I could use it instead. It isn't in the search path.
So I figure I need Xcode commandline tools.
Xcode is not currently available from the Software Update server
^ my current problem exactly. Comment on that question says "you can get this error if you have them already"
But how do I check whether I have them already?
/usr/bin/xcodebuild -version
will give you the xcode version, run it via Terminal command
This command allows you to retrieve Xcode version when having only the CommandLineTools version installed:
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
As per this answer to "Determine xcode command line tools version" on Ask Different
Notes:
Confirmed working on maxOS Sierra and Big Sur.
When only CommandLineTools is install without Xcode, using xcodebuild returns the following error:
# /usr/bin/xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
First of all, be sure that you have downloaded it or not. Open up your terminal application, and enter $ gcc if you have not installed it you will get an alert. You can verify that you have installed it by
$ xcode-select -p
/Library/Developer/CommandLineTools
And to be sure then enter $ gcc --version
You can read more about the process here: Xcode command line tools for Mavericks
if you want to know the install version of Xcode as well as Swift
language current version:
Use below simple command by using Terminal:
1. To get install Xcode Version
xcodebuild -version
2. To get install Swift language Version
swift --version
Thanks to the folks on Freenode's #macdev, here is some information:
In the old days before Xcode was on the app-store, it included commandline tools.
Now you get it from the store, and with this new mechanism it can't install extra things outside of the Xcode.app, so you have to manually do it yourself, by:
xcode-select --install
On Xcode 4.x you can check to see if they are installed from within the Xcode
UI:
On Xcode 5.x it is now here:
My problem of finding gcc/gdb is that they have been superseded by clang/lldb: GDB missing in OS X v10.9 (Mavericks)
Also note that Xcode contains compiler and debugger, so one of the things installing commandline tools will do is symlink or modify $PATH. It also downloads certain things like git.
If for some reason xcode is not installed under
/usr/bin/xcodebuild
execute the following command
which xcodebuild
and if it is installed, you'll be prompted with it's location.
I had XCode Commandline Tools installed for sure, but not XCode itself.
None of the available answers to get the version worked. pkgutil didn't give me the package of the XCode Commandline Tools, with none of the suggested package names.
Not having XCode installed (and having no need for it), I could not look in settings dialogs of that either.
xcode-select --version only gave me the version of xcode-select itself, with no clue as to the commandline tools version.
softwareupdate --list told me everything was up to date.
However I knew that my version must be out of date as the installer for one of homebrew packages told me so!
How I finally found out what version of the XCode Commandline Tools is installed I stumbled upon the command:
softwareupdate --history
Which listed 12.3 as the last version it updated...
Display Name Version Date
------------ ------- ----
Safari 14.0 04/11/2020, 12:26:12
Command Line Tools for Xcode 12.1 04/11/2020, 22:38:33
Safari 14.0.2 15/12/2020, 16:38:27
Safari 14.0.1 15/12/2020, 16:38:27
Command Line Tools for Xcode 12.3 15/12/2020, 16:38:27
macOS Big Sur 11.2.1 14/02/2021, 20:57:56
macOS Big Sur 11.2.2 11.2.2 08/03/2021, 09:02:20
So when you know for sure the commandline tools are installed (because, for instance, xcode-select --install tells you so) but none of the other methods works, check softwareupdate --history!
You can open the Xcode app and go to preferences, the last line shows you if you have tools installed, which tools and lets you change them from the drop-down:
If you have installed Xcode but haven't set the Xcode version. then you will be getting this error. To resolve
Xcode-> preferences -> Locations -> command line Tools -> Select the Xcode version
TL;DR
One can have multiple installations of Xcode and multiple installations of Command Line Tools. This is where the system thinks your CLT are
xcode-select --print-path
Options to select Command Line Tools is in Xcode > Preferences > Locations, including the path for each. I found that brew complains about Xcode or Command Line Tools, and so following details how to install specific version of either.
brew doctor issues after upgrade MacOS
I have always used App store to install and update Xcode on my (2014) Macbook Pro but today after all updates brew doctor was still complaining about Xcode
Warning: Your Xcode (12.4) is outdated.
Please update to Xcode 13.2.1 (or delete it).
and complaining about Command Line Tools
Warning: A newer Command Line Tools release is available.
Get the specific version of Xcode
Download a specific version of Xcode as a xip from Developer.apple.com (I downloaded Xcode_13.2.1.xip)
Move Xcode_13.2.1.xip to /Applications
cd Applications
xip --expand /Applications/Xcode_13.2.1.xip
It takes a while to download, then a while longer to validate the application.
Open /Applications/Xcode.app
Check the CLT in XCode
Xcode> Preferences> Locations shows available CLT and the location (path) of each.
Select the appropriate Command Line Tools
Copy the path.
Go to Terminal and use the path in xcode-select
sudo xcode-select -s /Users/<username>/Applications/Xcode.app
Close Terminal and reopen.
The following was not specific enough:
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
But this is good to identify the version
$ /usr/bin/xcodebuild -version
Xcode 13.2.1
Build version 13C100
IF still showing an older version of CLT
Try
sudo xcode-select --switch /Library/Developer/CommandLineTools/
THEN try
Update to a specific version of CLT
First, remove the existing CLT with
sudo rm -rf /Library/Developer/CommandLineTools
Check which CLT updates available
softwareupdate --list
Software Update Tool
Finding available software
Software Update found the following new or updated software:
Label: Command Line Tools for Xcode-12.4
Title: Command Line Tools for Xcode, Version: 12.4, Size: 440392K,> Recommended: YES,
Label: Command Line Tools for Xcode-13.2
Title: Command Line Tools for Xcode, Version: 13.2, Size: 577329K,> Recommended: YES,
Label: Command Line Tools for Xcode-12.5
Title: Command Line Tools for Xcode, Version: 12.5, Size: 470966K,> Recommended: YES,
Label: Command Line Tools for Xcode-12.5
Title: Command Line Tools for Xcode, Version: 12.5, Size: 470820K,> Recommended: YES,
softwareupdate --install "Command Line Tools for Xcode-13.2"
Closed Terminal and reopen
/usr/bin/xcodebuild -version
Xcode 13.2.1
Build version 13C100
Output from:
$ xcode-select -p
/Users/<username>/Applications/Xcode.app/Contents/Developer
And brew doctor shows
Your system is ready to brew.
For macOS catalina try this : open Xcode. if not existing. download from App store (about 11GB) then open Xcode>open developer tool>more developer tool and used my apple id to download a compatible command line tool. Then, after downloading, I opened Xcode>Preferences>Locations>Command Line Tool and selected the newly downloaded command line tool from downloads.

Xcode and Git installation on MacOSX Mountain Lion

I just installed Mountain Lion and Xcode, so under /Applications/Xcode.app/Contents/Developer/usr/bin I found the Git directory
But when I use Git commands in the shell terminal it returns error of command not found. Any suggestions? I have many Git repos on my mac, so I would like to reuse them without checking them out again :/
You need to install the command line tools (see Xcode -> Preferences -> Downloads) or you can download it from the Apple Developer Download site.
First of all, installing the Xcode Command Line tools is probably not what you want. See this post for more information:
http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
You want to set up symbolic links or aliases that point to the versions of git (and svn etc.) that exist inside Xcode.app. This will cause you to automatically get newer versions when Xcode updates through the app store. Installing the command line tools will only confuse matters because you will end up with multiple versions of git lying around, and you will have to manually update the command line tools.
The commands you will need are:
sudo xcode-select --switch /Applications/Xcode.app # tells 'xcrun' where to look
And then in your shell profile, for example .bash_profile:
alias git='xcrun git' # use 'xcrun' to locate the git binary
Now running 'git' from the terminal will use the latest version inside Xcode.app.

Xcode 4.5 Command Line Tools - xcode-select issue

After installing Xcode CLT 4.5.1 on OS X 10.8.2, I'm having issues installing native ruby gems which need to compiled.
The output error is the same as with running xcrun -find:
xcode-select: Error: No Xcode is selected. Use xcode-select -switch , or
see the xcode-select manpage (man xcode-select) for further information.
To which CLT location should xcode-select point to, since it's no longer at /Developer?
Edit: I don't have the Xcode app installed, only CLT.
The new location seems to be (be sure to run as root):
sudo xcode-select -switch /Library/Developer/
Since your Xcode tools are installed in /usr/bin, you should
sudo xcode-select -switch /
With XCode 4.5 installed AND Command Line Tools installed, I had to use this to get MacPorts and other similar things (like Ruby Gems or Perl CPAN module installation) working:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
I found that /Library/Developer did not work. Note that the Developer folder is not under /Library for me, it's under the app bundle file content folders.
I'm not sure why this is, but people googling this issue may come here and want to know the other commandline options that are commonly usable with xcode-select, thus this answer, even though it doesn't 100% apply to the original question (where command line tools are installed WITHOUT XCode).
you probably want:
xcode-select -switch /Applications/Xcode.app
unless you have multiple installs. that is likely the location if you have one install (e.g. from the App Store). if you have multiple installs, you probably know which one you want.
you could also try updating this value from Xcode's Preferences > Locations > Command Line Tools popup.
Open XCode and go to preferences.
Verify that there is an option under "Command Line Tools"
The error went away for me, as soon as I specified my Xcode command line tools version.
I got further from #jbowes xcode-select -switch /Library/Developer/ answer, but then I hit this:
xcrun: Error: failed to exec real xcrun. (No such file or directory)
I came across this thread (OSX 10.8 xcrun (No such file or directory)) which references a Gist that solved my problem:
https://gist.github.com/thelibrarian/5520597
It's gross, but it seems to be the only way to solve the issue with just the Command Line Tools (i.e. not a full-blown XCode installation).

How can I resolve "Error: No developer directory found at /Developer"?

I just upgraded XCode to 4.3.1.
I'm using a script to build (and then deploy through Testflight) my app.
But I now receive this error:
Error: No developer directory found at /Developer. Run /usr/bin/xcode-select to update the developer directory path.
I've no /Developer dir in my machine: how can I fix it?
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
You could also do this instead ...
sudo ln -s /Applications/Xcode.app/Contents/Developer /Developer
Everything you guys answered is correct. But for those who hit the following error are missing a step:
Error:
"xcode-select: Error: Path "/Applications/Xcode.app/Contents/Developer" is not a directory."
Missing step:
Double click your xcode 432.dmg. Now don't double click the xcode.app to use it. Instead copy it /Applications folder and then open it from there to install xcode.
Now use terminal command
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Thats it. Your error won't happen again and
Filemerge will work now.
This solved for me:
Mostly this error occurs when you have installed a newer version of xcode. And the command line tools are yet to be initialized.
To resolve this: Go under Xcode Preferences > Locations (tab) > And the bottom options is Command Line Tools. Please select the Xcode version for tools.
Example (For Xcode 8.3.3): Go under Xcode Preferences > Locations (tab) > And the bottom options is Command Line Tools. Select Xcode 8.3.3 (7D1014).

Resources