nodejs/node · error · GypError
Error %d running %s
Error message
Error %d running %s
What it means
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`.
Source
Thrown at tools/gyp/pylib/gyp/xcode_emulation.py:1562
continue
regex = re.compile(r"Command Line Tools for Xcode\s+(?P<version>\S+)")
try:
output = GetStdout(["/usr/sbin/softwareupdate", "--history"])
if m := re.search(regex, output):
return m.groupdict()["version"]
except (GypError, OSError):
return None
def GetStdoutQuiet(cmdlist):
"""Returns the content of standard output returned by invoking |cmdlist|.
Ignores the stderr.
Raises |GypError| if the command return with a non-zero return code."""
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = job.communicate()[0].decode("utf-8")
if job.returncode != 0:
raise GypError("Error %d running %s" % (job.returncode, cmdlist[0]))
return out.rstrip("\n")
def GetStdout(cmdlist):
"""Returns the content of standard output returned by invoking |cmdlist|.
Raises |GypError| if the command return with a non-zero return code."""
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE)
out = job.communicate()[0].decode("utf-8")
if job.returncode != 0:
sys.stderr.write(out + "\n")
raise GypError("Error %d running %s" % (job.returncode, cmdlist[0]))
return out.rstrip("\n")
def MergeGlobalXcodeSettingsToSpec(global_dict, spec):
"""Merges the global xcode_settings dictionary into each configuration of the
target represented by spec. For keys that are both in the global and the local
xcode_settings dict, the local key gets precedence.View on GitHub (pinned to 1b2de5e052)
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.
Example fix
# terminal diagnosis # before: gyp fails with 'Error <N> running xcodebuild' xcodebuild -version # see the actual error # after sudo xcodebuild -license accept
Defensive patterns
Strategy: try-catch
Try / catch
from gyp.common import GypError
try:
out = GetStdoutQuiet(['xcodebuild', '-version'])
except GypError as e:
print(f'xcodebuild failed: {e}. Accept license or reset path.')
raise Prevention
- Accept the Xcode license after install: `sudo xcodebuild -license accept`.
- Validate the developer directory: `xcrun --show-dev-dir`.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- xcodebuild returned unexpected results
- No Xcode or CLT version detected!
- Multiple toolsets not supported in xcode build (target %s)
- %s while executing command '%s' in %s
- stabs debug format is not supported yet.
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/167c084220d245b7.
Report an issue: GitHub.