I'd like to script the installation of the the Xcode Command Line Tools.
On Mavericks,
xcode-select --install
will open a dialog prompting the user to install, but I'd like to trigger the install without the dialog, like using the softwareupdate
command.
Is there a way to do this?
Edit:
Specifically, xcode-select --install
launches an application that downloads and installs the tools without requiring the user to manually download them or have an Apple Developer account. It appears to use /System/Library/CoreServices/Install Command Line Developer Tools.app
to do this.
I would like to use the same mechanism that Apple is, but without the GUI. I do not want to have to manually download the .dmg containing the tools as this seems fragile. Apple provides several other command-line tools, like softwareupdate
and install
that download or install software directly from Apple, and I'm looking to find the same for this type of distribution.
Best Answer
Wish I could claim credit for this one, but I found it buried in https://github.com/chcokr/osx-init/blob/master/install.sh
This worked on my 10.10 headless VM without a logged in UI. Updates applied for compatibility with at least 10.9-10.14
This presumes you only have 1 result to
softwareupdate -l | grep "\*.*Command Line"
- if this returns multiple versions, you might need more specific logic. (I dont have a repro case)one variation that seems to work (limited testing) on 10.10-10.14 (10.9 doesn't return an osx version number in the cli tools name..so this doesn't work there):
a few example results: