nodejs/node · error · Exception
--depfile requires --stamp and vice versa
Error message
--depfile requires --stamp and vice versa
What it means
The inspector-protocol code_generator.py emits a depfile (a make/ninja dependency list) only when it also has a stamp file to write, and vice versa. It enforces this with `bool(arg_options.depfile) != bool(arg_options.stamp)`, so exactly one of the two being set is an error; both empty or both set is fine.
Source
Thrown at deps/inspector_protocol/code_generator.py:87
cmdline_parser = argparse.ArgumentParser()
cmdline_parser.add_argument("--output_base", type=unicode, required=True)
cmdline_parser.add_argument("--jinja_dir", type=unicode, required=True)
cmdline_parser.add_argument("--config", type=unicode, required=True)
cmdline_parser.add_argument("--config_value", default=[], action="append")
cmdline_parser.add_argument(
"--inspector_protocol_dir", type=unicode, required=True,
help=("directory with code_generator.py and C++ encoding / binding "
"libraries, relative to the root of the source tree."))
cmdline_parser.add_argument("--depfile", type=unicode, required=False)
cmdline_parser.add_argument("--stamp", type=unicode, required=False)
arg_options = cmdline_parser.parse_args()
jinja_dir = arg_options.jinja_dir
output_base = arg_options.output_base
config_file = arg_options.config
config_base = os.path.dirname(config_file)
config_values = arg_options.config_value
if bool(arg_options.depfile) != bool(arg_options.stamp):
raise Exception("--depfile requires --stamp and vice versa")
depfile = arg_options.depfile
stamp = arg_options.stamp
inspector_protocol_dir = arg_options.inspector_protocol_dir.lstrip('/')
except Exception:
# Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
exc = sys.exc_info()[1]
sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc)
exit(1)
try:
config_json_file = open(config_file, "r")
config_json_string = config_json_file.read()
config_partial = json_to_object(config_json_string, output_base,
config_base)
config_json_file.close()
defaults = {
".use_snake_file_names": False,
".use_title_case_methods": False,View on GitHub (pinned to 1b2de5e052)
Solutions
- Supply both --depfile <path> and --stamp <path>, or omit both.
- If you added --depfile to capture dependencies, add the matching --stamp so the build knows when to regenerate.
- Check the calling gyp/gn action and align the two argument lists.
Example fix
# before python code_generator.py --depfile out/dep.d ... # after python code_generator.py --depfile out/dep.d --stamp out/stamp ...
Defensive patterns
Strategy: validation
Validate before calling
if bool(args.depfile) != bool(args.stamp):
raise SystemExit('--depfile and --stamp must be supplied together or both omitted') Prevention
- Always template --depfile and --stamp as a pair in gn/gyp action rules.
- Add a unit test on the build rule that both flags move together.
When it happens
Trigger: Raised in main() when exactly one of --depfile / --stamp is passed via the command line. Both are argparse optional strings, so the XOR check is the only guard.
Common situations: GYP/gn rule edits that wired up depfile generation but forgot the stamp target (or the reverse); partial ports of the inspector-protocol build rule to a new generator; manual invocation while debugging the protocol bindings.
Related errors
- --depfile requires --stamp and vice versa
- Dictionary key is not a string.
- Dictionary key is not a valid GN identifier.
- Unsupported type when printing to GN.
- --enable-v8windbg is incompatible with --without-bundled-v8.
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/20ec2515745438af.
Report an issue: GitHub.