{"record":{"id":"1c6fe527634016ed","repo":"nodejs/node","slug":"no-xcode-or-clt-version-detected","errorCode":null,"errorMessage":"No Xcode or CLT version detected!","messagePattern":"No Xcode or CLT version detected!","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/xcode_emulation.py","lineNumber":1512,"sourceCode":"        return XCODE_VERSION_CACHE\n    version = \"\"\n    build = \"\"\n    try:\n        version_list = GetStdoutQuiet([\"xcodebuild\", \"-version\"]).splitlines()\n        # In some circumstances xcodebuild exits 0 but doesn't return\n        # the right results; for example, a user on 10.7 or 10.8 with\n        # a bogus path set via xcode-select\n        # In that case this may be a CLT-only install so fall back to\n        # checking that version.\n        if len(version_list) < 2:\n            raise GypError(\"xcodebuild returned unexpected results\")\n        version = version_list[0].split()[-1]  # Last word on first line\n        build = version_list[-1].split()[-1]  # Last word on last line\n    except (GypError, OSError):\n        # Xcode not installed so look for XCode Command Line Tools\n        version = CLTVersion()  # macOS Catalina returns 11.0.0.0.1.1567737322\n        if not version:\n            raise GypError(\"No Xcode or CLT version detected!\")\n    # Be careful to convert \"4.2.3\" to \"0423\" and \"11.0.0\" to \"1100\":\n    version = version.split(\".\")[:3]  # Just major, minor, micro\n    version[0] = version[0].zfill(2)  # Add a leading zero if major is one digit\n    version = (\"\".join(version) + \"00\")[:4]  # Limit to exactly four characters\n    XCODE_VERSION_CACHE = (version, build)\n    return XCODE_VERSION_CACHE\n\n\n# This function ported from the logic in Homebrew's CLT version check\ndef CLTVersion():\n    \"\"\"Returns the version of command-line tools from pkgutil.\"\"\"\n    # pkgutil output looks like\n    #   package-id: com.apple.pkg.CLTools_Executables\n    #   version: 5.0.1.0.1.1382131676\n    #   volume: /\n    #   location: /\n    #   install-time: 1382544035\n    #   groups: com.apple.FindSystemFiles.pkg-group","sourceCodeStart":1494,"sourceCodeEnd":1530,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/xcode_emulation.py#L1494-L1530","documentation":"Raised by XcodeVersion() as a last resort when neither `xcodebuild -version` nor CLTVersion() can determine a version. CLTVersion() checks pkgutil package receipts and softwareupdate history for Command Line Tools; if all of those return None, gyp has no way to know which compiler toolchain version to target and aborts.","triggerScenarios":"xcodebuild is unavailable or returns bad data (caught by except), then CLTVersion() returns None because none of the known pkgutil package IDs (com.apple.pkg.CLTools_Executables, etc.) match and softwareupdate history has no matching entry.","commonSituations":"Fresh macOS installation with neither Xcode nor Command Line Tools installed. After a major macOS upgrade that removed or invalidated CLT receipts. A system where pkgutil receipts are missing or corrupted.","solutions":["Install Command Line Tools: run `xcode-select --install` and complete the GUI prompt.","If Xcode is preferred, install it from the Mac App Store and run `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer`.","After install, accept the license: `sudo xcodebuild -license accept` (for Xcode) — gyp needs a working toolchain.","Verify CLT detection by running `/usr/sbin/pkgutil --pkg-info com.apple.pkg.CLTools_Executables` and confirming a version line appears."],"exampleFix":"# terminal fix\nxcode-select --install\n# then verify\nxcrun --show-version","handlingStrategy":"validation","validationCode":"# Pre-flight check: ensure a toolchain is detectable\nimport subprocess, shutil\nif not shutil.which('xcodebuild'):\n    print('No Xcode found. Install CLT: xcode-select --install')","typeGuard":null,"tryCatchPattern":"from gyp.common import GypError\ntry:\n    XcodeVersion()\nexcept GypError as e:\n    if 'No Xcode or CLT' in str(e):\n        print('Install Command Line Tools: xcode-select --install')\n    raise","preventionTips":["Run `xcode-select --install` on fresh macOS setups before building with gyp.","In CI, pre-install CLT or Xcode and accept the license in the image setup."],"tags":["xcode","gyp","macos","environment","command-line-tools"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}