bazelbuild/bazel · error
Expected 3 arguments, got %d\n
Error message
Expected 3 arguments, got %d\n
What it means
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.
Source
Thrown at src/tools/launcher/launcher_maker.cc:64
if (!blaze_util::AsAbsoluteWindowsPath(path, &wpath, &error)) {
fprintf(stderr, "Failed to make absolute path for %s: %s\n", path,
error.c_str());
exit(1);
}
return wpath;
}
#else // _WIN32
#define STRING_TYPE std::string
#define STRING_FORMAT "%s"
std::string convert_path(char* path) { return path; }
#endif // _WIN32
int main(int argc, char** argv) {
if (argc < 4) {
fprintf(stderr, "Expected 3 arguments, got %d\n", argc);
return 1;
}
STRING_TYPE launcher_path = convert_path(argv[1]);
STRING_TYPE info_params = convert_path(argv[2]);
STRING_TYPE output_path = convert_path(argv[3]);
std::ifstream src(launcher_path.c_str(), std::ios::binary);
if (!src.good()) {
fprintf(stderr, "Failed to open " STRING_FORMAT ": %s\n",
launcher_path.c_str(), strerror(errno));
return 1;
}
std::ofstream dst(output_path.c_str(), std::ios::binary);
if (!dst.good()) {
fprintf(stderr, "Failed to create " STRING_FORMAT ": %s\n",
output_path.c_str(), strerror(errno));
return 1;View on GitHub (pinned to e6e199d060)
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.
Example fix
# before: launcher_maker.exe launcher.exe # after: launcher_maker.exe launcher.exe launch-info.txt my-launcher.exe
Defensive patterns
Strategy: validation
Validate before calling
if (argc != 4) {
fprintf(stderr, "usage: %s <launcher> <info-file> <output>\n", argv[0]);
return 1;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Hand-testing the tool; custom rules that build the args list conditionally and skip a parameter.
Related errors
- Failed to make absolute path for %s: %s\n
- Usage: %s -- command arg1 @args
- \nUsage: %s -- command arg1 @args\n
- Failed to open " STRING_FORMAT ": %s\n
- Failed to create " STRING_FORMAT ": %s\n
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/6f45b5f8c5347a32.
Report an issue: GitHub.