How to check if XCode command line tools are installed?

10.15 Catalina Update:

See Yosemite Update.

10.14 Mojave Update:

See Yosemite Update.

10.13 High Sierra Update:

See Yosemite Update.

10.12 Sierra Update:

See Yosemite Update.

10.11 El Capitan Update:

See Yosemite Update.

10.10 Yosemite Update:

Just enter in gcc or make on the command line! OSX will know that you do not have the command line tools and prompt you to install them!

To check if they exist, xcode-select -p will print the directory. Alternatively, the return value will be 2 if they do NOT exist, and 0 if they do. To just print the return value (thanks @Andy):

xcode-select -p 1>/dev/null;echo $?

10.9 Mavericks Update:

Use pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

10.8 Update:

Option 1: Rob Napier suggested to use pkgutil --pkg-info=com.apple.pkg.DeveloperToolsCLI, which is probably cleaner.

Option 2: Check inside /var/db/receipts/com.apple.pkg.DeveloperToolsCLI.plist for a reference to com.apple.pkg.DeveloperToolsCLI and it will list the version 4.5.0.

[Mar 12 17:04] [jnovack@yourmom ~]$ defaults read /var/db/receipts/com.apple.pkg.DeveloperToolsCLI.plist
{
    InstallDate = "2012-12-26 22:45:54 +0000";
    InstallPrefixPath = "/";
    InstallProcessName = Xcode;
    PackageFileName = "DeveloperToolsCLI.pkg";
    PackageGroups =     (
        "com.apple.FindSystemFiles.pkg-group",
        "com.apple.DevToolsBoth.pkg-group",
        "com.apple.DevToolsNonRelocatableShared.pkg-group"
    );
    PackageIdentifier = "com.apple.pkg.DeveloperToolsCLI";
    PackageVersion = "4.5.0.0.1.1249367152";
    PathACLs =     {
        Library = "!#acl 1\\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C:everyone:12:deny:delete\\n";
        System = "!#acl 1\\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C:everyone:12:deny:delete\\n";
    };
}

Leave a Comment