4
$ type git
git is hashed (/usr/bin/git)
$ /usr/bin/git --version
git version 2.24.3 (Apple Git-128)
$ pkgutil --pkgs | grep ^com.apple
com.apple.update.fullbundleupdate.19H2
com.apple.pkg.update.os.10.15.7Supplemental.19H15
com.apple.pkg.EmbeddedOSFirmware
com.apple.update.fullbundleupdate.19H15
com.apple.update.fullbundleupdate.19G2021
com.apple.pkg.update.os.10.15.7.19H2
com.apple.pkg.SecureBoot
com.apple.pkg.update.os.SecUpd2020-001Catalina.19H114
com.apple.pkg.update.os.10.15.6Supplemental.19G2021
com.apple.pkg.Core
com.apple.update.fullbundleupdate.19H114
com.apple.pkg.XProtectPlistConfigData_10_15.16U4147
com.apple.files.data-template
com.apple.pkg.XProtectPlistConfigData_10_15.16U4145
com.apple.pkg.MRTConfigData_10_15.16U4142
com.apple.pkg.MRTConfigData_10_15.16U4146
com.apple.pkg.IncompatibleAppList.10_15.16U1923
com.apple.pkg.Pages10
com.apple.pkg.iMovie_AppStore
com.apple.pkg.Keynote10
com.apple.pkg.Numbers10
$ ls /Applications/Xcode.app
ls: /Applications/Xcode.app: No such file or directory

As you can see, I have neither the Command Line Tools, nor Xcode installed, yet I still have Command Line Tools. How is this possible? Is there something that I'm missing?

1
  • what makes you think you have command line tools installed?
    – Natsfan
    Feb 13, 2021 at 2:18

2 Answers 2

4

Git being there means some part of the CLT is there, since the shim doesn't come up, and since Xcode is not installed.

It is a known problem that the receipt for the CLT may disappear. One documentation of this is by MacPorts, linked here.

  • Download the command line tools package from the ​Apple Developer site.

  • If the version of the CLT you need is not listed at the developer site, but an older version is, reinstalling that will restore the package receipts. Then just run Software Update to trigger the update to the newer version.

  • Or, on Mac OS X 10.9 or greater, Software Update can reinstall the package:

    sudo touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
    softwareupdate -l
    sudo rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
    
0

Exactly what Marc Wilson said. I had neither Xcode, nor the com.apple.pkg.CLTools_Executables package:

$ pkgutil --pkg-info com.apple.pkg.CLTools_Executables
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
$ pkgutil --pkg-info com.apple.pkg.CLTools_Base
No receipt for 'com.apple.pkg.CLTools_Base' found at '/'.
$ ls /Applications/Xcode.app
ls: /Applications/Xcode.app: No such file or directory
$ 

Yet:

$ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ git --version
git version 2.24.3 (Apple Git-128)
$ 

Confusingly, Homebrew was working without any problems and was reporting a version for Command Line Tools (CLT) when I ran brew config, meaning that it thinks that CLT are installed.

Looking into Homebrew code, I understood that this method detects the CLT version:

def detect_version
  version = nil
  [EXECUTABLE_PKG_ID, MAVERICKS_NEW_PKG_ID].each do |id|
    next unless File.exist?("#{PKG_PATH}/usr/bin/clang")

    version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1]
    return version if version
  end

  detect_version_from_clang_version
end

where:

  • EXECUTABLE_PKG_ID is set to com.apple.pkg.CLTools_Executables
  • MAVERICKS_NEW_PKG_ID is set to com.apple.pkg.CLTools_Base

in the same file. That is, it was checking for the presence of these packages, and if neither are found, it was running the detect_version_from_clang_version method to detect the CLT version.

I used the GitHub interface for git blame on that file and understood that the detect_version_from_clang_version line was added on this commit, replacing the detect_clang_version line.

To understand when, in turn, detect_clang_version line was added, I started looking at the commit history of the file starting from that commit. While looking at the commit history, I noticed this commit message:

os/mac/xcode: fallback to clang version for detecting CLT.

For some reason pkgutil --pkgs no longer lists the CLT after the Catalina supplemental update.

Fixes #6610

I opened that commit and understood that indeed it is the commit that introduced detect_clang_version line to the detect_version method.

So, in short, most likely some software updates are causing some package receipts to be removed, even though the package is still there.

You must log in to answer this question.

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