{"record":{"id":"167c084220d245b7","repo":"nodejs/node","slug":"error-d-running-s","errorCode":null,"errorMessage":"Error %d running %s","messagePattern":"Error (.+?) running (.+?)","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/xcode_emulation.py","lineNumber":1562,"sourceCode":"            continue\n\n    regex = re.compile(r\"Command Line Tools for Xcode\\s+(?P<version>\\S+)\")\n    try:\n        output = GetStdout([\"/usr/sbin/softwareupdate\", \"--history\"])\n        if m := re.search(regex, output):\n            return m.groupdict()[\"version\"]\n    except (GypError, OSError):\n        return None\n\n\ndef GetStdoutQuiet(cmdlist):\n    \"\"\"Returns the content of standard output returned by invoking |cmdlist|.\n    Ignores the stderr.\n    Raises |GypError| if the command return with a non-zero return code.\"\"\"\n    job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n    out = job.communicate()[0].decode(\"utf-8\")\n    if job.returncode != 0:\n        raise GypError(\"Error %d running %s\" % (job.returncode, cmdlist[0]))\n    return out.rstrip(\"\\n\")\n\n\ndef GetStdout(cmdlist):\n    \"\"\"Returns the content of standard output returned by invoking |cmdlist|.\n    Raises |GypError| if the command return with a non-zero return code.\"\"\"\n    job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)\n    out = job.communicate()[0].decode(\"utf-8\")\n    if job.returncode != 0:\n        sys.stderr.write(out + \"\\n\")\n        raise GypError(\"Error %d running %s\" % (job.returncode, cmdlist[0]))\n    return out.rstrip(\"\\n\")\n\n\ndef MergeGlobalXcodeSettingsToSpec(global_dict, spec):\n    \"\"\"Merges the global xcode_settings dictionary into each configuration of the\n    target represented by spec. For keys that are both in the global and the local\n    xcode_settings dict, the local key gets precedence.","sourceCodeStart":1544,"sourceCodeEnd":1580,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/xcode_emulation.py#L1544-L1580","documentation":"Raised by GetStdoutQuiet(cmdlist) when a subprocess command returns a non-zero exit code. This wrapper captures stderr separately (discards it) and raises a GypError with the exit code and the command name. It is used internally by XcodeVersion() to invoke `xcodebuild -version`.","triggerScenarios":"subprocess.Popen(cmdlist, ...) completes with job.returncode != 0. For GetStdoutQuiet this is most commonly xcodebuild failing due to a missing or broken Xcode install, an unaccepted license, or an invalid developer path.","commonSituations":"Xcode license not yet accepted after a fresh install. xcode-select pointing to a non-existent directory. A macOS update broke the active developer directory. xcodebuild crashing or requiring an update.","solutions":["Run the failing command directly in a terminal to see its stderr: `xcodebuild -version`.","Accept the Xcode license: `sudo xcodebuild -license accept`.","Reset the developer path: `sudo xcode-select -r` or point to the correct Xcode with `-s`.","Reinstall/repair Xcode or Command Line Tools if the binary is missing or crashes."],"exampleFix":"# terminal diagnosis\n# before: gyp fails with 'Error <N> running xcodebuild'\nxcodebuild -version  # see the actual error\n# after\nsudo xcodebuild -license accept","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from gyp.common import GypError\ntry:\n    out = GetStdoutQuiet(['xcodebuild', '-version'])\nexcept GypError as e:\n    print(f'xcodebuild failed: {e}. Accept license or reset path.')\n    raise","preventionTips":["Accept the Xcode license after install: `sudo xcodebuild -license accept`.","Validate the developer directory: `xcrun --show-dev-dir`."],"tags":["xcode","gyp","macos","subprocess","environment"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}