Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
This worked for me in attempting to re-install Mac OS X Lion (previously bought in App Store) on an old Macbook. Benign error messages: Checksum failed. Expected 7425D663 but got 84E748B9 Could not restore - Invalid argument
I looked in the source code of homebrew and Homebrew/os/mac/xcode.rb looks to use this type of approach. Looking at homebrew was interesting to me as I could see the evolution of the CLT integration in MacOS.
@fd0 looks to be the way to go. On a clean Sierra MacOS 10.12.1: ENTER: $ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables RESULT: No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'. ENTER: $ echo $? RESULT: 1
In macOS Sierra 10.12.2, if CLT is already installed xcode-select --install 2>&1 results in stderr: xcode-select: error: command line tools are already installed, use "Software Update" to install updates, but you wouldn't want to suppress that either for the case when it isn't installed. I'm stumped.