Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Xcode Command Line Tools?

I am trying to update Command line tools on my mac osx.

~  softwareupdate --list Software Update Tool Copyright 2002-2015 Apple Inc.  Finding available software Software Update found the following new or updated software:        * Command Line Tools (macOS El Capitan version 10.11) for Xcode-8.2     Command Line Tools (macOS El Capitan version 10.11) for Xcode (8.2), 150374K [recommended]    * iTunesX-12.5.5     iTunes (12.5.5), 263476K [recommended] 

But when I run the update command, I get this error:

softwareupdate -i Command Line Tools (macOS El Capitan version 10.11) for Xcode-8.2 zsh: number expected 

This doesn't work either:

softwareupdate -i Command Line Tools Software Update Tool Copyright 2002-2015 Apple Inc.  Command: No such update Line: No such update Tools: No such update No updates are available. 

What specific string should I specify after sofwareupdate -i command?

like image 817
Akshay Khot Avatar asked Mar 01 '17 17:03

Akshay Khot


People also ask

How do I update Xcode Tools on Mac?

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).

How do I open Xcode command line tools on a Mac?

Start Xcode on the Mac. Choose Preferences from the Xcode menu. In the General window, click the Locations tab. On the Location window, check that the Command Line Tools option shows the Xcode version (with which the Command Line Tools were installed).


2 Answers

For future travelers, here's a version-agnostic approach. First, run softwareupdate --list. This will probably take a couple of minutes. When it's done, you'll see a bulleted (with an asterisk) output like this:

$ softwareupdate --list Software Update Tool  Finding available software Software Update found the following new or updated software:    * Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1         Command Line Tools (macOS High Sierra version 10.13) for Xcode (10.1), 190584K [recommended] 

Find the bullet that refers to the Xcode command line tools. Copy that entire line (except the asterisk...). In the above case, you would copy: Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1

Then, run the install command (as shown by Brendan Shanks) with what you copied inside quotes:

softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1" 
like image 100
M Falanga Avatar answered Sep 17 '22 03:09

M Falanga


I'm going to answer a slightly different question here, because this question came up when I searched for a solution to my problem. Hopefully it'll help someone (and it'll surely help me next time I run into the same issue).

I wanted to upgrade the command line tools from version 8 to 9. The App Store didn't suggest this upgrade, and neither did softwareupdate --list.

xcode-select --install 

installed the new version of the tools. But clang --version still gave 8.0.0 as the version number. xcode-select -r and rebooting didn't solve this issue.

xcode-select -p returned /Applications/Xcode.app/Contents/Developer, and clang --version reported an installation directory under there. I thought I'd start over again.

sudo rm -rf /Applications/Xcode.app 

deleted version 8 of the tools. But xcode-select --install said the command line tools were already installed.

sudo xcode-select -r 

Now, sudo xcode-select -p returns /Library/Developer/CommandLineTools/.

It seems that the problem was that the new version of the tools are installed to a different directory, and xcode-select -r is not clever enough to find the latest version.

like image 29
Cris Luengo Avatar answered Sep 18 '22 03:09

Cris Luengo