How to update Xcode from command line
I am trying to update Xcode from the command line. Initially I tried running:
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
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.
Read more... Read less...
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
I got this error after deleting Xcode. I fixed it by resetting the command line tools path with
sudo xcode-select -r.
[email protected] ~$ /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. [email protected] ~$ xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates
[email protected] ~$ /usr/bin/clang clang: error: no input files
$ sudo rm -rf /Library/Developer/CommandLineTools $ xcode-select --install
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)