43

I performed a fresh install of macOS Mojave 10.14. Immediately after that I installed Xcode Version 10.0 (10A255) from the Mac App Store.

Now, I wish to install Homebrew which requires Xcode Command Line Tools to be installed. My understanding is that installing Xcode also installs the Command Line Tools. Or not?

As per this answer, I checked if the Command Line Tools are installed by running:

xcode-select -p

which printed the path for the Developer directory as follows:

/Applications/Xcode.app/Contents/Developer

As suggested in the answer, I also verified the return value by running:

echo $?

which retuned 0.

I also ran, gcc and make and bash was able to locate and execute them.

Thus far I am convinced that the Xcode Command Line Tools are installed. Now when I execute:

xcode-select --install

I get this alert:

enter image description here

What's the probable reason for this disparity? Will this install Xcode Command Line Tools twice? Or overwrite the existing installation?

As I understand, Xcode Command Line Tools can be installed without installing Xcode. Also, from my previous experience, if the Command Line Tools aren't installed separately from Xcode (by running xcode-select --install), they are not detected by Homebrew, i.e. when running brew config, the value for CLT: is shown as N/A.

Here's the complete picture (pardon the pun):

enter image description here

Although I am talking in context of macOS Mojave, the question remains the same with regard to previous versions of macOS.

What is the advisable approach to take here?

Note: After installing Xcode, I launched it, accepted license agreement and let it finish its run of installing additional tools (which is a one time activity).

2

4 Answers 4

32

Apparently, there is some distinction between the command line tools installed for use by Xcode and the tools installed for system-wide use:

For my machine, running xcode-select --install and choosing to install the tools from the window that popped up helped fix the problem. I was able to confirm that it was fixed when running brew config and seeing a valid entry for CLT:

macOS: 10.14-x86_64
CLT: 10.0.0.0.1.1535735448
Xcode: 10.0
3
  • 1
    (commenting for seo) I'm here because my git commands were failing. This answer was the fix I needed to get git commands working again eg. git branch etc
    – Jacksonkr
    Commented Dec 29, 2018 at 19:41
  • 1
    You can also select an Xcode version for the CLT from within Xcode's preferences on the Location tab. You'll see tons of references online to a "downloads" tab, which no longer exists. Can anyone shed light on what this selection in Xcode actually does? brew config confirms I have the CLT installed, but Qt is whining that I need Xcode 5 (yes, 5, WTH). Apparently this CLT selection has something to do with it.
    – Oscar
    Commented Jan 22, 2019 at 0:40
  • @Oscar I know I'm a bit late but to answer your question: it runs xcode-select. The manpage says: "xcode-select controls the location of the developer directory used by xcrun(1), xcodebuild(1), cc(1), and other Xcode and BSD development tools. This also controls the locations that are searched for by man(1) for developer tool manpages." This also applies to shims like /usr/bin/ar (which aren't actually symlinks, rather they act like xcrun ar).
    – Coder-256
    Commented Mar 21, 2021 at 20:39
27

I had the same problem after upgrading to Mojave. Running

xcode-select --install

Led to the error

Can't install the software because it is not currently available from the Software Update server

Downloading the command line tools from developer.apple.com finally resolved the problem.

1
1

I ran into a similar issue trying to install some python packages (with jsonnet as dependency), and found a solution here. After running;

xcode-select --install

Apparently you still have to install the package, which you can do from terminal;

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Although Steven already answered your question, I hope this helps someone!

1
# Install Command-line tools as dependency for Homebrew
xcode-select --install # Sets the development directory path to /Library/Developer/CommandLineTools

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Mas (command-line interface for Mac App Store)
brew install mas

# Search for Xcode showing only the first 5 results
mas search xcode | head -5
# Install Xcode using App ID
mas install 497799835 # The appid for Xcode shown when doing search

sudo xcode-select -r  # Reset the development directory path to put to Xcode /Applications/Xcode.app/Contents/Developer

#sudo xcodebuild -license

# Updaate all Apple software and auto agree to any licenses and restart if necessary
sudo softwareupdate --install --agree-to-license -aR
2
  • HWt does this show?
    – mmmmmm
    Commented Jan 26, 2021 at 20:20
  • Using the mas CLI is a super cool trick. +1 without some edits, most people won’t be able to make good use of this, but it’s a handy cheat sheet
    – bmike
    Commented Jan 26, 2021 at 20:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .