{"record":{"id":"c7241bbf2985775e","repo":"bazelbuild/bazel","slug":"nusage-s-command-arg1-args-n","errorCode":null,"errorMessage":"\\nUsage: %s -- command arg1 @args\\n","messagePattern":"\\\\nUsage: (.+?) -- command arg1 @args\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/tools/process-wrapper-options.cc","lineNumber":40,"sourceCode":"\n#include <cstring>\n#include <memory>\n#include <string>\n#include <vector>\n\n#include \"src/main/tools/logging.h\"\n\nstruct Options opt;\n\n// Print out a usage error. argc and argv are the argument counter and vector,\n// fmt is a format, string for the error message to print.\nstatic void Usage(char *program_name, const char *fmt, ...) {\n  va_list ap;\n  va_start(ap, fmt);\n  vfprintf(stderr, fmt, ap);\n  va_end(ap);\n\n  fprintf(stderr, \"\\nUsage: %s -- command arg1 @args\\n\", program_name);\n  fprintf(\n      stderr,\n      \"\\nPossible arguments:\\n\"\n      \"  -g/--graceful_sigterm  propagate SIGTERM to the subprocess and delay \"\n      \"the corresponding SIGKILL until --kill_delay has passed\\n\"\n      \"  -t/--timeout <timeout>  timeout after which the child process will be \"\n      \"terminated with SIGTERM\\n\"\n      \"  -k/--kill_delay <timeout>  in case timeout occurs, how long to wait \"\n      \"before killing the child with SIGKILL\\n\"\n      \"  -o/--stdout <file>  redirect stdout to a file\\n\"\n      \"  -e/--stderr <file>  redirect stderr to a file\\n\"\n      \"  -s/--stats <file>  if set, write stats in protobuf format to a file\\n\"\n      \"  -d/--debug  if set, debug info will be printed\\n\"\n      \"  --  command to run inside sandbox, followed by arguments\\n\");\n  exit(EXIT_FAILURE);\n}\n\n// Parses command line flags from an argv array and puts the results into the","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/tools/process-wrapper-options.cc#L22-L58","documentation":"Usage() is process-wrapper's argument parser error path: it prints the specific parse message, then this usage line and the option list (-g/--graceful_sigterm, -t/--timeout, -k/--kill_delay, -o/--stdout, -e/--stderr, -s/--stats, ...) and exits nonzero. Bazel launches every local action through process-wrapper, so a user normally sees it only from manual experimentation or a client/tool version skew that produced unknown options.","triggerScenarios":"Invoking process-wrapper by hand without the mandatory '-- command' separator or using linux-sandbox-style flags (-l/-L) that this tool does not accept; running with --strategy=process-wrapper-sanitize? no—mismatched flag sets caused by mixing Bazel binaries of different versions in one output base.","commonSituations":"Debugging action timeouts by rerunning the process-wrapper command from --subcommands; leftover process-wrapper from an old Bazel on PATH; scripts wrapping the tool with extra args.","solutions":["Re-run the exact argv captured with --subcommands (quote it verbatim, keep the '--').","Use the long names shown in the usage text (--timeout, --kill_delay) instead of guessing short flags.","Resolve version skew: bazel clean --expunge and a fresh single-version install.","For timeout experiments, prefer --test_timeout or --spawn_timeout on bazel itself rather than hand-editing wrapper args."],"exampleFix":"# before: process-wrapper /bin/sleep 10\n# after:\nprocess-wrapper --timeout=5 --kill_delay=2 -- /bin/sleep 10","handlingStrategy":"validation","validationCode":"// reuse the same argv-shape guard: flags, then '--', then command\nbool ValidWrapperArgv(int argc, char **argv) {\n  for (int i = 1; i < argc; ++i)\n    if (strcmp(argv[i], \"--\") == 0) return i + 1 < argc;\n  return false;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer long option names (--timeout, --kill_delay, --stdout).","Keep the '--' separator; process-wrapper exits immediately without it.","Capture exact invocations with --subcommands before hand-tuning them.","Match process-wrapper and bazel versions (single install)."],"tags":["c","process-wrapper","usage","cli","argument-parsing","timeout"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}