How to update Xcode from command line - xcode

I am trying to update Xcode from the command line. Initially I tried running:
xcode-select --install
which resulted in this message:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
So the question remains, is there a way to update Xcode from the command line?

What you are actually using is the command to install the Xcode command line tools - xcode-select --install. Hence the error message you got - the tools are already installed.
The command you need to update Xcode is softwareupdate command [args ...]. You can use softwareupdate --list to see what's available and then softwareupdate --install -a to install all updates or softwareupdate --install <product name> to install just the Xcode update (if available). You can get the name from the list command.
As it was mentioned in the comments here is the man page for the softwareupdate tool.
2019 Update
A lot of users are experiencing problems where softwareupdate --install -a will in fact not update to the newest version of Xcode. The cause for this is more than likely a pending macOS update (as #brianlmerritt pointed out below). In most cases updating macOS first will solve the problem and allow Xcode to be updated as well.
Updating the Xcode Command Line Tools
A large portion of users are landing on this answer in an attempt to update the Xcode Command Line Tools. The easiest way to achieve this is by removing the old version of the tools, and installing the new one.
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
A popup will appear and guide you through the rest of the process.

I had the same issue and I solved by doing the following:
removing the old tools ($ sudo rm -rf /Library/Developer/CommandLineTools)
install xcode command line tools again ($ xcode-select --install).
After these steps you will see a pop to install the new version of the tools.

I encountered the same issue when I uninstalled the complete version of Xcode to reinstall the CLI version. My fix was:
sudo xcode-select -s /Library/Developer/CommandLineTools

After installing Command Line Tools (with xcode-select --install), type:
sudo xcode-select --switch /Library/Developer/CommandLineTools/
You should be able to run git now:
10:29 $ git --version
git version 2.17.2 (Apple Git-113)

I got this error after deleting Xcode. I fixed it by resetting the command line tools path with sudo xcode-select -r.
Before:
navin#Radiant ~$ /usr/bin/clang
xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.
navin#Radiant ~$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
After:
navin#Radiant ~$ /usr/bin/clang
clang: error: no input files

Just type the commands
cd /Library/Developer/CommandLineTools/Packages/;
open macOS_SDK_headers_for_macOS_10.14.pkg
Reference: https://forums.developer.apple.com/thread/104296

$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install

I was facing the same problem, resolved it by using the following command.
sudo xcode-select -s /Library/Developer/CommandLineTools
After running the above command then xcode-select -p command showed the following.
/Library/Developer/CommandLineTools

#Vel Genov's answer is correct, except when the version of Xcode can't be updated because it is the latest version for your current version of Mac OS. If you know there is a newer Xcode (for example, it won't load an app onto a device with a recent version of iOS) then it's necessary to first upgrade Mac OS.
Further note for those like me with old Mac Pro 5.1. Upgrading to Mojave required installing the metal gpu (Sapphire AMD Radeon RX 560 in my case) but make sure only HDMI monitor is installed (not 4K! 1080 only). Only then did install Mojave say firmware update required and shut computer down. Long 2 minute power button hold and it all upgraded fine after that!
Catalina update - softwareupdate --install -a won't upgrade xcode from command line if there is a pending update (say you selected update xcode overnight)

I am not sure why this was so tricky for me.
sudo xcode-select --install
Did nothing for me.
softwareupdate --all --install --force
Did nothing for me.
I had to do things in the following order
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
This installed a newer xcode, but not latest.
Then I did
softwareupdate --all --install --force
and they updated completely.

Xcode::Install is a simple cli software that allow you to install/select a specific Xcode version.
You can install it using gem install xcode-install
Then you will be able to install a specific version with xcversion install 9.4.1
And if you have more than one version installed, you can switch version with xcversion select 9.4
You can find more information at https://github.com/KrauseFx/xcode-install

I am now running OS Big Sur. xcode-select --install, and sudo xcode-select --reset did not resolve my issue, neither did the recommended subsequent softwareupdate --install -a command. For good measure, I tried the recommended download from Apple Downloads, but the Command Line Tools downloads available there are not compatible with my OS.
I upvoted the fix that resolved for me, sudo xcode-select --switch /Library/Developer/CommandLineTools/ and added this post for environment context.

I was able to update via CLI using:
softwareupdate --list --verbose
and then
softwareupdate -i Command\ Line\ Tools\ for\ Xcode-13.2

I was trying to use the React-Native Expo app with create-react-native-app but for some reason it would launch my simulator and just hang without loading the app. The above answer by ipinak above reset the Xcode CLI tools because attempting to update to most recent Xcode CLI was not working. the two commands are:
rm -rf /Library/Developer/CommandLineTools
xcode-select --install
This process take time because of the download.
I am leaving this here for any other would be searches for this specific React-Native Expo fix.

I was faced with this today after an update from Xcode (App Store on Mac) updated my Xcode.
My SourceTree wouldn't allow me to do a merge conflict.
In Xcode I found that Command Tools was NOT selected.
I selected it, however still no dice as I was getting the same message of:
I performed the command:
softwareupdate --list
which gave me a list of products, including THREE (3) versions of CommandLine Tools
Software Update Tool
Finding available software
Software Update found the following new or updated software:
Label: Command Line Tools for Xcode-13.2
Title: Command Line Tools for Xcode, Version: 13.2, Size: 577329K, Recommended: YES,
Label: SFSymbolsAuto-3.3
Title: SF Symbols, Version: 3.3, Size: 169368K, Recommended: YES,
Label: Command Line Tools for Xcode-13.3
Title: Command Line Tools for Xcode, Version: 13.3, Size: 718145K, Recommended: YES,
Label: Command Line Tools for Xcode-13.4
Title: Command Line Tools for Xcode, Version: 13.4, Size: 705462K, Recommended: YES,
my version of Xcode is 13.4, so I preceded to try to update just the one.
I used the Label, with escaped spaces (which also works with just quoted label btw "Command Line Tools for Xcode-13.4"
softwareupdate -i Command\ Line\ Tools\ for\ Xcode-13.4
In doing so, ALL 3 updates of Command Line Tools disappeared and I was able to continue.
Hope this helps someone else out there.

Hello I solved it like this:
Install Application> Xcode.app> Contents> Resources> Packages> XcodeSystemResources.pkg.

I arrived here trying to install Appium. Adding my answer in case other folks land here for the same issue.
appium-doctor --ios
... bunch of stuff...
WARN AppiumDoctor ✖ Error running xcrun simctl
... bunch of stuff...
info AppiumDoctor ### Manual Fixes Needed ###
info AppiumDoctor The configuration cannot be automatically fixed, please do the
following first:
WARN AppiumDoctor ➜ Manually install Xcode, and make sure 'xcode-select -p' command shows proper path like '/Applications/Xcode.app/Contents/Developer'
In my case
xcode-select -p
/Library/Developer/CommandLineTools
which appeared wrong...but I knew I had recently updated Xcode and the command line tools
so...
sudo xcode-select -r (sudo required)
then...
xcode-select -p
/Applications/Xcode.app/Contents/Developer
After this, no warning. Appium-doctor returned clean.

xCode version 11.2.1 is necessary for building app in iPad 13.2.3, When I directly try to upgrade from xcode 11.1 to 11.2.1 through App Store it get struck, So after some research , I found a solution to upgrade by removing the existing xcode from the system
So here I am adding the steps to upgrade after uninstalling existing xcode.
Go to Applications and identify Xcode and drag it to trash.
Empty trash to permenently delete Xcode.
Now go to ~/Library/Developer/ folder and remove the contents completely Use sudo rm -rf ~/Library/Developer/ to avoid any
permission issue while deleting
Lastly remove any cache directory associated with xcode in the path ~/Library/Caches/com.apple.dt.Xcode sudo rm -rf
~/Library/Caches/com.apple.dt.Xcode/*
After completing the above steps you can easly install xcode from App Store, which will install the current latest version of xcode
Note: Please take a backup of your existing projects before making the above changes

Update with this one-liner.
softwareupdate --install -a

This reminds me why I hate MacOS. Every time I tried one of these errors I would get the incomprehensible error: No install could be requested (perhaps no UI is present)
Turns out this "CLI" actually needs a graphical session to run. WTF! Very useful when you're actually only ever connecting to the remote mac server over SSH to queue iOS builds.
So the answer for me was:
Physically travel to the Mac, attach screen, mouse and keyboard, and run the command there.

To those having this issue after update to Catalina, just execute this command on your terminal
sudo rm -rf /Library/Developer/CommandLineTools; xcode-select --install;

Related

error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance [duplicate]

Saw the following error when running an npm install which required node-gyp... but could be triggered by anything which requires xcode-select.
xcode-select: error: tool 'xcodebuild' requires Xcode, but active
developer directory '/Library/Developer/CommandLineTools' is a command
line tools instance
What is the problem?
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools when a full regular Xcode was required (happens when CommandLineTools are installed after Xcode)
Solution:
Install Xcode (get it from https://appstore.com/mac/apple/xcode) if you don't have it yet.
Accept the Terms and Conditions.
Ensure Xcode app is in the /Applications directory (NOT /Users/{user}/Applications).
Point xcode-select to the Xcode app Developer directory using the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Note: Make sure your Xcode app path is correct.
Xcode: /Applications/Xcode.app/Contents/Developer
Xcode-beta: /Applications/Xcode-beta.app/Contents/Developer
Other solution for those who don't want to install Xcode:
Install Command Line Tools (if you haven't already):
xcode-select --install
Change the active directory:
sudo xcode-select -switch /Library/Developer/CommandLineTools
This worked for me (git).
I was having an issue while trying to install packages using npm.
I got the error: "sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/"
To fix this
I opened Xcode.
Preferences
Locations
Selected the Command Lin Tools: Xcode 6.1.1
Now when installing packages with npm I no longer get errors.
Xcode > Preferences > Locations > Command Line Tools
Select the option matching your version of Xcode.
Simply run sudo xcode-select -r which should automatically reset the path.
-r, --reset
Unsets any user-specified developer directory, so that the developer directory will be found via the default search mechanism. This command must be
run with superuser permissions (see sudo(8)), and will affect all users on the system.
I just ran the following command and the issue was resolved for me:
sudo xcode-select --reset
Type this in your terminal
xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
if you installed XCode already, All you have to do is to...
Open XCode
Go To Xcode > Preferences > Locations
From the Command Line Tools Select your XCode
Just in case you're using xcode beta:
sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
I had to run this first
sudo xcode-select --reset
then
sudo xcode-select -switch /Library/Developer/CommandLineTools
and then it worked.
Download Xcode from App Store.
Go to Xcode preferences/Locations/CommandlineTools
You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'
I was having the same problem in high sierra.
running the following command solved it
npm explore npm -g -- npm install node-gyp#latest
Please follow the steps below :
The latest version of Xcode can be downloaded from https://developer.apple.com/xcode/download/
It will be downloaded in the 'Downloads' unless specified otherwise. Please make sure to check the path where you have downloaded and extracted the Xcode
Now unlike other downloaded applications, on extraction, Xcode doesn't give the option to move it to Applications
Note the XCODE-ACTUAL-LOCATION or move it to the Applications
Note if you have downloaded Xcode or Xcode-beta
Based on 4 and 5, execute one of the commands (Do not execute all of them without reading above description):
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer
Install Xcode from App Store. After installing run xcodebuild with root privileges i.e. sudo xcodebuild and accept the language. After this npm install bcrypt worked like a charm!
Without Xcode: create file /usr/local/bin/xcodebuild with content to cheat XcodeSelect
#!/bin/bash
exit 0
chmod +x /usr/local/bin/xcodebuild
Simple reinstall xcode-select
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
In case you are using Xcode beta, run
sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer
instead of
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
I was able to solve this error without installing the full Xcode application. You must, however, have xcode command line tools installed.
From here:
$ cd /usr/bin
$ sudo mv xcodebuild xcodebuild.orig (A backup just in case)
$ vim xcodebuild
Paste the following:
#!/bin/bash
if [[ $1 == '-version' ]]; then
echo "Xcode 10.2.1"
echo "Build version 10E1001"
else
/usr/bin/xcodebuild.bak $#
fi
$ sudo chmod +x xcodebuild
XCode2:
sudo xcode-select -s /Applications/Xcode\ 2.app/Contents/Developer
Pay attention to the "\" to escape the space
I had two instance of Xcode installed xcode.app and xcode-beta.app
When I tried to create a build with netbeans it showed me the error
"supported version of xcode and command line tools not found netbeans"
I followed the following steps:
"xcode-select --print-path" is equal to "/Applications/Xcode.app/Contents/Developer"
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform" exists
"xcodebuild -version" starts with "Xcode"
after 1 I found that it is pointing me to xcode-beta.app
so here is the solution which worked like a charm:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
For context, today is Jan 28, 2019.
On my Mac, I did two things to resolve this problem:
Run the following command in your terminal:
sudo xcode-select --install
Restart your Mac.
Until I restarted the computer, the problem kept occurring in my Android Studio. After reboot, it was working just fine. Also note that I did not execute any --switch commands as others are doing. I hope this helps.
Manually installing Command LineTool worked for me.
I stalled xcode through App Store
Still could not download Homebrew
I installed Command Line Tool manually through link.
Bing Bang Boom
https://developer.apple.com/download/more/?=command%20line%20tools
sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
because my Xcode name in Application is "Xcode 10",
sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
works.
In my case,
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
didn't work because my Xcode had some special name. eg) Xcode_11.2.0_beta_2_stackoverflow.app
cd /applications
ls
Then I found my Xcode name, then replace it with
sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer
It worked for me.
None of the above worked for me. I originally installed Command Line Tools separately, and then all of Xcode. What worked for me was to uninstall Command Line Tools as shown here. Then, when trying to run xcode-select again, I was asked to reinstall them.
*By the way, the very reason why I found this thread was because I had installed some libraries (particularly gcc) with macports, presumably using the old Command Line Tools, and then I installed the full Xcode midway into development. So anyways, for my case, I had to reinstall macports after removing the stand-alone Command Line Tools, reinstalling them, reinstalling gcc, and then my compilation worked.
There are only two steps required, and the full XCode.app is not required at all:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
At this point the "Installing Softwre" dialog pops up:
That's it!
None of the above solutions helped me. I was working on an old project, and I had the latest version of NodeJs installed globally (v14.x) on my computer.
No node version above 10.1.x worked for me and when testing I received the same error as above.
Solution
I installed "n" which is a nodeJs version manager like nvm
I downgraded my nodeJs version to 9.x
npm install now works.
I will now need to update my versions, or Specify my node version in my package.json.
The simple fix that worked for me is drag and drop Xcode.app from the current location (In my case it was in downloads) to Applications.

Errors during make test installing kibana via homebrew on Mac (xcode issue?) [duplicate]

Saw the following error when running an npm install which required node-gyp... but could be triggered by anything which requires xcode-select.
xcode-select: error: tool 'xcodebuild' requires Xcode, but active
developer directory '/Library/Developer/CommandLineTools' is a command
line tools instance
What is the problem?
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools when a full regular Xcode was required (happens when CommandLineTools are installed after Xcode)
Solution:
Install Xcode (get it from https://appstore.com/mac/apple/xcode) if you don't have it yet.
Accept the Terms and Conditions.
Ensure Xcode app is in the /Applications directory (NOT /Users/{user}/Applications).
Point xcode-select to the Xcode app Developer directory using the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Note: Make sure your Xcode app path is correct.
Xcode: /Applications/Xcode.app/Contents/Developer
Xcode-beta: /Applications/Xcode-beta.app/Contents/Developer
I was having an issue while trying to install packages using npm.
I got the error: "sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/"
To fix this
I opened Xcode.
Preferences
Locations
Selected the Command Lin Tools: Xcode 6.1.1
Now when installing packages with npm I no longer get errors.
Other solution for those who don't want to install Xcode:
Install Command Line Tools (if you haven't already):
xcode-select --install
Change the active directory:
sudo xcode-select -switch /Library/Developer/CommandLineTools
This worked for me (git).
Xcode > Preferences > Locations > Command Line Tools
Select the option matching your version of Xcode.
Simply run sudo xcode-select -r which should automatically reset the path.
-r, --reset
Unsets any user-specified developer directory, so that the developer directory will be found via the default search mechanism. This command must be
run with superuser permissions (see sudo(8)), and will affect all users on the system.
I just ran the following command and the issue was resolved for me:
sudo xcode-select --reset
Type this in your terminal
xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
if you installed XCode already, All you have to do is to...
Open XCode
Go To Xcode > Preferences > Locations
From the Command Line Tools Select your XCode
Just in case you're using xcode beta:
sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
I had to run this first
sudo xcode-select --reset
then
sudo xcode-select -switch /Library/Developer/CommandLineTools
and then it worked.
Download Xcode from App Store.
Go to Xcode preferences/Locations/CommandlineTools
You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'
I was having the same problem in high sierra.
running the following command solved it
npm explore npm -g -- npm install node-gyp#latest
Please follow the steps below :
The latest version of Xcode can be downloaded from https://developer.apple.com/xcode/download/
It will be downloaded in the 'Downloads' unless specified otherwise. Please make sure to check the path where you have downloaded and extracted the Xcode
Now unlike other downloaded applications, on extraction, Xcode doesn't give the option to move it to Applications
Note the XCODE-ACTUAL-LOCATION or move it to the Applications
Note if you have downloaded Xcode or Xcode-beta
Based on 4 and 5, execute one of the commands (Do not execute all of them without reading above description):
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer
Install Xcode from App Store. After installing run xcodebuild with root privileges i.e. sudo xcodebuild and accept the language. After this npm install bcrypt worked like a charm!
Without Xcode: create file /usr/local/bin/xcodebuild with content to cheat XcodeSelect
#!/bin/bash
exit 0
chmod +x /usr/local/bin/xcodebuild
Simple reinstall xcode-select
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
In case you are using Xcode beta, run
sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer
instead of
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
I was able to solve this error without installing the full Xcode application. You must, however, have xcode command line tools installed.
From here:
$ cd /usr/bin
$ sudo mv xcodebuild xcodebuild.orig (A backup just in case)
$ vim xcodebuild
Paste the following:
#!/bin/bash
if [[ $1 == '-version' ]]; then
echo "Xcode 10.2.1"
echo "Build version 10E1001"
else
/usr/bin/xcodebuild.bak $#
fi
$ sudo chmod +x xcodebuild
XCode2:
sudo xcode-select -s /Applications/Xcode\ 2.app/Contents/Developer
Pay attention to the "\" to escape the space
I had two instance of Xcode installed xcode.app and xcode-beta.app
When I tried to create a build with netbeans it showed me the error
"supported version of xcode and command line tools not found netbeans"
I followed the following steps:
"xcode-select --print-path" is equal to "/Applications/Xcode.app/Contents/Developer"
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform" exists
"xcodebuild -version" starts with "Xcode"
after 1 I found that it is pointing me to xcode-beta.app
so here is the solution which worked like a charm:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
For context, today is Jan 28, 2019.
On my Mac, I did two things to resolve this problem:
Run the following command in your terminal:
sudo xcode-select --install
Restart your Mac.
Until I restarted the computer, the problem kept occurring in my Android Studio. After reboot, it was working just fine. Also note that I did not execute any --switch commands as others are doing. I hope this helps.
Manually installing Command LineTool worked for me.
I stalled xcode through App Store
Still could not download Homebrew
I installed Command Line Tool manually through link.
Bing Bang Boom
https://developer.apple.com/download/more/?=command%20line%20tools
sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
because my Xcode name in Application is "Xcode 10",
sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
works.
In my case,
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
didn't work because my Xcode had some special name. eg) Xcode_11.2.0_beta_2_stackoverflow.app
cd /applications
ls
Then I found my Xcode name, then replace it with
sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer
It worked for me.
None of the above worked for me. I originally installed Command Line Tools separately, and then all of Xcode. What worked for me was to uninstall Command Line Tools as shown here. Then, when trying to run xcode-select again, I was asked to reinstall them.
*By the way, the very reason why I found this thread was because I had installed some libraries (particularly gcc) with macports, presumably using the old Command Line Tools, and then I installed the full Xcode midway into development. So anyways, for my case, I had to reinstall macports after removing the stand-alone Command Line Tools, reinstalling them, reinstalling gcc, and then my compilation worked.
There are only two steps required, and the full XCode.app is not required at all:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
At this point the "Installing Softwre" dialog pops up:
That's it!
None of the above solutions helped me. I was working on an old project, and I had the latest version of NodeJs installed globally (v14.x) on my computer.
No node version above 10.1.x worked for me and when testing I received the same error as above.
Solution
I installed "n" which is a nodeJs version manager like nvm
I downgraded my nodeJs version to 9.x
npm install now works.
I will now need to update my versions, or Specify my node version in my package.json.
The simple fix that worked for me is drag and drop Xcode.app from the current location (In my case it was in downloads) to Applications.

xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist

I'm having xcode issues when I try to use brew and git:
xcrun: error: active developer path ("/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)
I can type xcode-select and it shows that the command exists. When I type xcode-select -p it shows:
/Applications/Xcode.app/Contents/Developer
but when I do which xcode-select, it gives me:
/usr/bin/xcode-select
I've tried to use the command switch and install again via Apple Developer site but none of these options have work so far... How can I fix this?
I tried that and it didn't work but I found the answer. I just had to reset the developer's path:
$ sudo xcode-select --reset
Now everything is normal
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 10.0 (10A255) ):
Go under Xcode Preferences > Locations (tab) > And the bottom options is Command Line Tools. Select Xcode 10.0 (10A255).
For more details please see this image:
In my case, I had uninstalled Xcode and then issues with git cli started. I solved the problem running the following commands:
$ sudo xcode-select -r
$ sudo xcode-select --switch /Library/Developer/CommandLineTools
and then validating new path with:
$ sudo xcode-select -p
I have faced the same issue as I have uninstalled the XCode abruptly, running the below command (from Terminal) helped me to resolve this.
sudo xcode-select -switch /
This error coming because xcode get deleted, corrupt or moved.
In my case i removed xcode from my Mac and faced the same issue.
I fixed it by simple two steps
Open Terminal
Simply run following command
sudo xcode-select -r
And now error has resolved. Hope it will helpful.
Use this:
sudo xcode-select -switch /
This should solve the problem.
How about what the error suggests? Did you try that?
xcode-select --switch /Applications/Xcode.app
That should do the trick.
For me it helps to install Xcode CLI
xcode-select --install
after uninstalling XCode (I don't develop for the OSx or iOS)
Then I could successfully build downloaded source with make
Try error suggestion :
sudo xcode-select --switch /Applications/Xcode.app
And Then test Git Executable Path.
I had the same problem and had to remove completely Developer tools, and reinstall:
$ rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
Tip: because Xcode had been improperly uninstalled, I had to manually (re)move the Xcode app, too:
$ mv /Applications/Xcode.app/ /Applications/Xcode.app.bak
In my case such error occurred after I has tried to symbolicate crash report, and according to a manual, entered command export DEVELOPER_DIR=”/Applications/Xcode.app/Contents/Developer”
I tried some proposed here solutions but nothing helped.
Then I realized that I have added an environment variable DEVELOPER_DIR to my terminal and this led to error: "xcrun: error: missing DEVELOPER_DIR path:"
Then I've just reboot my terminal, that cleaned the environment variable and the error disappeared.
(FYI: environment variables may be checked with printenv command in terminal)
for my mbp m1 apple sillicon for the case alr tried all the above answer and not solved.
i have solved by here discussion https://developer.apple.com/forums/thread/660641
there is have 2 option to solve, my case...
i have uninstalled xcode because i don't need again
install standalone mode, doesnt work. can't install the software
solved by try download manual command line tools check on the discussion thread for the link file ( 741.5 MB ) .

"xcrun: error: active developer path… does not exist, use xcode-select --switch" when trying to run git. How to fix?

I have been trying to instal the Git on my mac, But every time I use the command $git --version.
I get the following error
xcrun: error: active developer path ("/Volumes/Xcode/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)
I have already installed the Xcode on my mac for iOS App development.
I am not sure what this error is trying to say.
My case:
I removed XCode. JetBrains integration with git - breaks. Found this error in terminal.
My soltuion:
I don't want to download XCode to restore PyCharm. So I ran:
sudo xcode-select --reset
So from discussion in the comments above, it seems the right fix here is just to run the command /usr/bin/xcode-select -switch once (i.e., run it with the full path to the executable, rather than just as xcode-select) with /Applications/Xcode.app/Contents/Developer/ as the argument:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
After running that once, everything should work as expected from then on.
sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
and reboot your computer.
Try this below answer. It's worked for me.
Open your Xcode Preferences,
--> Select Locations
--> Select your specific Xcode version in Command Line Tools
It was easier for me to let Xcode pick the install location of Command Line Tools for me, instead of the other way around. After downloading the .xip file from the Apple Developer downloads page, expanding the compressed contents, and installing Xcode.App, I was able to open it using Spotlight.
And open preferences:
And select my Command Line Tools under "Locations".
You can install git via the brew package manager for Mac. I recommend installing software this way since it's a great way to manage your installed packages in one place. For example, you can do brew update to get a list of the latest package updates, or brew upgrade to upgrade all of your software installed through brew.
To install brew, open a terminal window and run:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update your brew packages with brew update
Install git with brew install git
I had installed git, then returned to a terminal window open prior to the installation. I try running command git --version and this raised error message below. To resolve, I ran command source /etc/profile in same terminal window. BTW, terminal window is inside my Webstorm and my end goal is to git init and setup git for my new reactjs project. Happy coding!
The error:
xcrun: error: active developer path ("/Volumes/Xcode/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\`)

xcode-select active developer directory error

Saw the following error when running an npm install which required node-gyp... but could be triggered by anything which requires xcode-select.
xcode-select: error: tool 'xcodebuild' requires Xcode, but active
developer directory '/Library/Developer/CommandLineTools' is a command
line tools instance
What is the problem?
This problem happens when xcode-select developer directory was pointing to /Library/Developer/CommandLineTools when a full regular Xcode was required (happens when CommandLineTools are installed after Xcode)
Solution:
Install Xcode (get it from https://appstore.com/mac/apple/xcode) if you don't have it yet.
Accept the Terms and Conditions.
Ensure Xcode app is in the /Applications directory (NOT /Users/{user}/Applications).
Point xcode-select to the Xcode app Developer directory using the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Note: Make sure your Xcode app path is correct.
Xcode: /Applications/Xcode.app/Contents/Developer
Xcode-beta: /Applications/Xcode-beta.app/Contents/Developer
I was having an issue while trying to install packages using npm.
I got the error: "sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/"
To fix this
I opened Xcode.
Preferences
Locations
Selected the Command Lin Tools: Xcode 6.1.1
Now when installing packages with npm I no longer get errors.
Other solution for those who don't want to install Xcode:
Install Command Line Tools (if you haven't already):
xcode-select --install
Change the active directory:
sudo xcode-select -switch /Library/Developer/CommandLineTools
This worked for me (git).
Xcode > Preferences > Locations > Command Line Tools
Select the option matching your version of Xcode.
Simply run sudo xcode-select -r which should automatically reset the path.
-r, --reset
Unsets any user-specified developer directory, so that the developer directory will be found via the default search mechanism. This command must be
run with superuser permissions (see sudo(8)), and will affect all users on the system.
I just ran the following command and the issue was resolved for me:
sudo xcode-select --reset
Type this in your terminal
xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
if you installed XCode already, All you have to do is to...
Open XCode
Go To Xcode > Preferences > Locations
From the Command Line Tools Select your XCode
Just in case you're using xcode beta:
sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer
I had to run this first
sudo xcode-select --reset
then
sudo xcode-select -switch /Library/Developer/CommandLineTools
and then it worked.
Download Xcode from App Store.
Go to Xcode preferences/Locations/CommandlineTools
You just have to set it to the Xcode version. It automatically points to '/Application/Xcode.app'
I was having the same problem in high sierra.
running the following command solved it
npm explore npm -g -- npm install node-gyp#latest
Simple reinstall xcode-select
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Please follow the steps below :
The latest version of Xcode can be downloaded from https://developer.apple.com/xcode/download/
It will be downloaded in the 'Downloads' unless specified otherwise. Please make sure to check the path where you have downloaded and extracted the Xcode
Now unlike other downloaded applications, on extraction, Xcode doesn't give the option to move it to Applications
Note the XCODE-ACTUAL-LOCATION or move it to the Applications
Note if you have downloaded Xcode or Xcode-beta
Based on 4 and 5, execute one of the commands (Do not execute all of them without reading above description):
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer
Install Xcode from App Store. After installing run xcodebuild with root privileges i.e. sudo xcodebuild and accept the language. After this npm install bcrypt worked like a charm!
Without Xcode: create file /usr/local/bin/xcodebuild with content to cheat XcodeSelect
#!/bin/bash
exit 0
chmod +x /usr/local/bin/xcodebuild
In case you are using Xcode beta, run
sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer
instead of
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
I was able to solve this error without installing the full Xcode application. You must, however, have xcode command line tools installed.
From here:
$ cd /usr/bin
$ sudo mv xcodebuild xcodebuild.orig (A backup just in case)
$ vim xcodebuild
Paste the following:
#!/bin/bash
if [[ $1 == '-version' ]]; then
echo "Xcode 10.2.1"
echo "Build version 10E1001"
else
/usr/bin/xcodebuild.bak $#
fi
$ sudo chmod +x xcodebuild
XCode2:
sudo xcode-select -s /Applications/Xcode\ 2.app/Contents/Developer
Pay attention to the "\" to escape the space
I had two instance of Xcode installed xcode.app and xcode-beta.app
When I tried to create a build with netbeans it showed me the error
"supported version of xcode and command line tools not found netbeans"
I followed the following steps:
"xcode-select --print-path" is equal to "/Applications/Xcode.app/Contents/Developer"
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform" exists
"xcodebuild -version" starts with "Xcode"
after 1 I found that it is pointing me to xcode-beta.app
so here is the solution which worked like a charm:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
For context, today is Jan 28, 2019.
On my Mac, I did two things to resolve this problem:
Run the following command in your terminal:
sudo xcode-select --install
Restart your Mac.
Until I restarted the computer, the problem kept occurring in my Android Studio. After reboot, it was working just fine. Also note that I did not execute any --switch commands as others are doing. I hope this helps.
Manually installing Command LineTool worked for me.
I stalled xcode through App Store
Still could not download Homebrew
I installed Command Line Tool manually through link.
Bing Bang Boom
https://developer.apple.com/download/more/?=command%20line%20tools
sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
because my Xcode name in Application is "Xcode 10",
sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"
works.
In my case,
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
didn't work because my Xcode had some special name. eg) Xcode_11.2.0_beta_2_stackoverflow.app
cd /applications
ls
Then I found my Xcode name, then replace it with
sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer
It worked for me.
None of the above worked for me. I originally installed Command Line Tools separately, and then all of Xcode. What worked for me was to uninstall Command Line Tools as shown here. Then, when trying to run xcode-select again, I was asked to reinstall them.
*By the way, the very reason why I found this thread was because I had installed some libraries (particularly gcc) with macports, presumably using the old Command Line Tools, and then I installed the full Xcode midway into development. So anyways, for my case, I had to reinstall macports after removing the stand-alone Command Line Tools, reinstalling them, reinstalling gcc, and then my compilation worked.
There are only two steps required, and the full XCode.app is not required at all:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
At this point the "Installing Softwre" dialog pops up:
That's it!
None of the above solutions helped me. I was working on an old project, and I had the latest version of NodeJs installed globally (v14.x) on my computer.
No node version above 10.1.x worked for me and when testing I received the same error as above.
Solution
I installed "n" which is a nodeJs version manager like nvm
I downgraded my nodeJs version to 9.x
npm install now works.
I will now need to update my versions, or Specify my node version in my package.json.
The simple fix that worked for me is drag and drop Xcode.app from the current location (In my case it was in downloads) to Applications.

Resources