How to update Xcode Command Line Tools?

Akshay Khot picture Akshay Khot · Mar 1, 2017 · Viewed 84.5k times · Source

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?

Answer

M Falanga picture M Falanga · Nov 18, 2018

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"