software_writer
software_writer

Reputation: 4478

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?

Upvotes: 75

Views: 142577

Answers (9)

M Falanga
M Falanga

Reputation: 2077

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"

Upvotes: 114

captam3rica
captam3rica

Reputation: 351

If softwareupdate is not seeing any available CLI tool updates, you can do the following to trick softwareupdate into showing everything it has regarding CLI tools.

# Trick softwareupdate into giving us everything it knows about Xcode CLI tools by
# touching the following file to /tmp
xclt_tmp="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
/usr/bin/touch "${xclt_tmp}"

# run softwareupdate --list --all again to see if there is anything for CLI tools
softwareupdate --list --all

After running the above, you should see something like the below if there are any updates available for the Xcode CLI tools.

Software Update Tool

Finding available software
Software Update found the following new or updated software:
* Label: Command Line Tools for Xcode-14.0
        Title: Command Line Tools for Xcode, Version: 14.0, Size: 687109KiB, Recommended: YES, 
* Label: Command Line Tools for Xcode-14.2
        Title: Command Line Tools for Xcode, Version: 14.2, Size: 687573KiB, Recommended: YES, 

Upvotes: 7

user3064538
user3064538

Reputation:

Update everything with

softwareupdate -i -a

Upvotes: 2

Antonin
Antonin

Reputation: 1830

The answer given by brew (when using an old version of Command Line Tools):

Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force

If that doesn't show you any updates, run:

sudo rm -rf /Library/Developer/CommandLineTools

sudo xcode-select --install

It worked for me, while softwareupdate --list did not show anything and softwareupdate --all --install --force answered No updates are available..

Upvotes: 9

bjelli
bjelli

Reputation: 10090

when upgrading to MacOS Catalina, Version 10.15.* you can install the command line tools for xcode 11.3 like this:

$ softwareupdate --list
Software Update Tool

Finding available software
Software Update found the following new or updated software:
* Label: Command Line Tools for Xcode-11.3
    Title: Command Line Tools for Xcode, Version: 11.3, Size: 224878K, Recommended: YES,
$ sudo softwareupdate -i "Command Line Tools for Xcode-11.3"

Upvotes: 4

Hanny
Hanny

Reputation: 1342

I faced similar problem on MacOS Mojave version 10.14.3 with Xcode 10.3 installed. The real problem was, when I installed the Xcode 10.3, I deleted the "Xcode-beta.app" first and then installed the new version. Therefore, when I tried installing CLion for C++ development and configuring it, CMake gave me error And Updating Command Line Tool didnt work for me:

softwareupdate -i "Command Line Tools (macOS Mojave version 10.14.3) for Xcode-10.3"

and showed me this response in terminal

Software Update Tool
Command Line Tools (macOS Mojave version 10.14.3) for Xcode-10.3: No such update
No updates are available.

Then I tried to check the version of Clang using:

clang --version

And the response lead me to the real problem i.e. Active Developer path was still pointing to Old version of Xcode that I had already deleted.

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

Therefore, I switched the active developer path to latest Xcode App installed using:

sudo xcode-select --switch /Applications/Xcode.app

And everything worked like a charm automatically.

Upvotes: 8

Cris Luengo
Cris Luengo

Reputation: 60761

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.

Upvotes: 40

software_writer
software_writer

Reputation: 4478

I ran the same command with sudo and that did the trick.

sudo softwareupdate -i "Command Line Tools (macOS El Capitan version 10.11) for Xcode-8.2"

Upvotes: 2

Brendan Shanks
Brendan Shanks

Reputation: 3236

Run softwareupdate -i "Command Line Tools (macOS El Capitan version 10.11) for Xcode-8.2". The quotes are important.

Upvotes: 10

Related Questions