{"record":{"id":"c8ab14e521b680e1","repo":"nodejs/node","slug":"call-to-s-returned-exit-status-d-while-in-s","errorCode":null,"errorMessage":"Call to '%s' returned exit status %d while in %s.","messagePattern":"Call to '(.+?)' returned exit status (.+?) while in (.+?)\\.","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/input.py","lineNumber":976,"sourceCode":"                    # Fix up command with platform specific workarounds.\n                    contents = FixupPlatformCommand(contents)\n                    try:\n                        # stderr will be printed no matter what\n                        result = subprocess.run(\n                            contents,\n                            stdout=subprocess.PIPE,\n                            shell=use_shell,\n                            cwd=build_file_dir,\n                            check=False,\n                        )\n                    except Exception as e:\n                        raise GypError(\n                            \"%s while executing command '%s' in %s\"\n                            % (e, contents, build_file)\n                        )\n\n                    if result.returncode > 0:\n                        raise GypError(\n                            \"Call to '%s' returned exit status %d while in %s.\"\n                            % (contents, result.returncode, build_file)\n                        )\n                    replacement = result.stdout.decode(\"utf-8\").rstrip()\n\n                cached_command_results[cache_key] = replacement\n            else:\n                gyp.DebugOutput(\n                    gyp.DEBUG_VARIABLES,\n                    \"Had cache value for command '%s' in directory '%s'\",\n                    contents,\n                    build_file_dir,\n                )\n                replacement = cached_value\n\n        elif contents not in variables:\n            if contents[-1] in [\"!\", \"/\"]:\n                # In order to allow cross-compiles (nacl) to happen more naturally,","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/input.py#L958-L994","documentation":"For <!() command expansions, GYP runs the command via subprocess.run and, if result.returncode is greater than zero, raises this GypError with the command, the exit status, and the build file. stderr is intentionally not captured so it streams to the console, which usually tells you why the command failed. The command's stdout (only produced on success) is what gets substituted.","triggerScenarios":"A '<!(cmd)' expansion runs a script/program that exits non-zero — the codegen tool failed, the script hit an internal error, missing input file, wrong CLI flags, or a flaky network call inside the command.","commonSituations":"A codegen script that errors on missing input; wrong CLI flags after a tool upgrade; a script that depends on env vars (PATH, OUT_DIR) not set in the gyp environment; flaky commands during distributed builds; a helper that returns non-zero on warnings-as-errors.","solutions":["Look immediately above the GypError in the log — stderr was printed live and explains the failure.","Re-run the exact command (from the .gyp file's directory) to reproduce and fix the underlying tool/script.","Make the command tolerant of missing inputs if that is intended, or fix the inputs so it succeeds.","Ensure required env vars are exported before invoking gyp."],"exampleFix":"// before — script exits 1 on missing template\n'version': '<!(./gen_version.py)',\n// after — pass the template path the script expects\n'version': '<!(./gen_version.py --template ./tmpl.h)',","handlingStrategy":"validation","validationCode":"import subprocess\nrc = subprocess.run(cmd, shell=True, cwd=build_file_dir).returncode\nassert rc == 0, f'<!() command exited {rc}: {cmd}'","typeGuard":"def command_succeeds(cmd: str, cwd: str) -> bool:\n    import subprocess\n    return subprocess.run(cmd, shell=True, cwd=cwd).returncode == 0","tryCatchPattern":"try:\n    gyp.process_build_file(...)\nexcept gyp.input.GypError as e:\n    if 'returned exit status' in str(e):\n        log_full_stderr_context(e)","preventionTips":["Treat <!() commands as part of the build — test them in CI like any other step.","Make codegen scripts exit non-zero only on real errors, never on warnings, to keep gyp green.","Set required env vars (PATH, OUT_DIR, etc.) in the gyp wrapper script."],"tags":["gyp","subprocess","command-expansion","exit-code","build-config"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}