{"record":{"id":"6f45b5f8c5347a32","repo":"bazelbuild/bazel","slug":"expected-3-arguments-got-d-n","errorCode":null,"errorMessage":"Expected 3 arguments, got %d\\n","messagePattern":"Expected 3 arguments, got (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/tools/launcher/launcher_maker.cc","lineNumber":64,"sourceCode":"  if (!blaze_util::AsAbsoluteWindowsPath(path, &wpath, &error)) {\n    fprintf(stderr, \"Failed to make absolute path for %s: %s\\n\", path,\n            error.c_str());\n    exit(1);\n  }\n  return wpath;\n}\n\n#else  // _WIN32\n\n#define STRING_TYPE std::string\n#define STRING_FORMAT \"%s\"\nstd::string convert_path(char* path) { return path; }\n\n#endif  // _WIN32\n\nint main(int argc, char** argv) {\n  if (argc < 4) {\n    fprintf(stderr, \"Expected 3 arguments, got %d\\n\", argc);\n    return 1;\n  }\n\n  STRING_TYPE launcher_path = convert_path(argv[1]);\n  STRING_TYPE info_params = convert_path(argv[2]);\n  STRING_TYPE output_path = convert_path(argv[3]);\n\n  std::ifstream src(launcher_path.c_str(), std::ios::binary);\n  if (!src.good()) {\n    fprintf(stderr, \"Failed to open \" STRING_FORMAT \": %s\\n\",\n            launcher_path.c_str(), strerror(errno));\n    return 1;\n  }\n  std::ofstream dst(output_path.c_str(), std::ios::binary);\n  if (!dst.good()) {\n    fprintf(stderr, \"Failed to create \" STRING_FORMAT \": %s\\n\",\n            output_path.c_str(), strerror(errno));\n    return 1;","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/tools/launcher/launcher_maker.cc#L46-L82","documentation":"launcher_maker's main requires exactly three positional arguments (launcher binary, launch-info params file, output executable); argc must be at least 4 (program name + 3). If fewer are passed it prints the count it actually received and returns exit code 1. Bazel generates these actions internally, so hitting it manually or via a broken rule means the action's argv is malformed.","triggerScenarios":"Running launcher_maker with 0-2 arguments; a custom Starlark action accidentally dropping the output argument; shell scripts mangling quoted paths into a single argv entry.","commonSituations":"Hand-testing the tool; custom rules that build the args list conditionally and skip a parameter.","solutions":["Invoke with exactly three paths: launcher_maker <launcher> <info-file> <output>.","Inspect the failing action with --subcommands to see the actual argv Bazel produced.","Fix custom action definitions so all three ctx.actions.run() args are always supplied.","Quote paths in wrapper scripts so spaces do not collapse argument counts."],"exampleFix":"# before: launcher_maker.exe launcher.exe\n# after: launcher_maker.exe launcher.exe launch-info.txt my-launcher.exe","handlingStrategy":"validation","validationCode":"if (argc != 4) {\n  fprintf(stderr, \"usage: %s <launcher> <info-file> <output>\\n\", argv[0]);\n  return 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply all three positional paths in order.","Quote paths with spaces so argv counts stay correct.","In Starlark actions, build args from a fixed list so none can be dropped."],"tags":["windows","launcher","usage","cli","argument-count"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}