{"record":{"id":"40f0d00009649dd6","repo":"bazelbuild/bazel","slug":"failed-to-open-string-format-s-n","errorCode":null,"errorMessage":"Failed to open \" STRING_FORMAT \": %s\\n","messagePattern":"Failed to open \" STRING_FORMAT \": (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/tools/launcher/launcher_maker.cc","lineNumber":74,"sourceCode":"#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;\n  }\n  dst << src.rdbuf();\n\n  std::ifstream info_file(info_params.c_str());\n  if (!info_file.good()) {\n    fprintf(stderr, \"Failed to open \" STRING_FORMAT \": %s\\n\",\n            info_params.c_str(), strerror(errno));\n    return 1;\n  }\n  int64_t bytes = 0;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/tools/launcher/launcher_maker.cc#L56-L92","documentation":"launcher_maker opens argv[1] — the base launcher binary shipped with Bazel — with std::ifstream in binary mode; if the stream is not good() it prints the path (wide-string aware via STRING_FORMAT '%ls' on Windows) plus strerror(errno) and exits 1. It means the launcher template file does not exist or is not readable at the moment the action runs.","triggerScenarios":"The launcher binary path argument points to a missing/moved file; the file exists but permissions deny read; the path contains characters mishandled by the shell so it resolves to a nonexistent name.","commonSituations":"Custom rules passing a wrong launcher location; antivirus quarantining the launcher exe; output base pruned mid-build by an external cleaner.","solutions":["Verify the printed path exists and is readable (type <path> on Windows).","Check the errno text: 'No such file or directory' → fix the argument; 'Permission denied' → fix ACLs or AV exclusions.","Ensure nothing deletes runfiles/output-base content concurrently (bazel clean while a build runs).","For custom rules, use a files= dep on the launcher so Bazel materializes it before the action."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify the launcher input exists and is readable before running the action\nstruct stat st;\nif (stat(launcher_path.c_str(), &st) != 0 || !(st.st_mode & S_IREAD)) {\n  fprintf(stderr, \"missing/unreadable launcher: %s\\n\", launcher_path.c_str());\n  return 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare the launcher binary as an action input so Bazel materializes it first.","Keep AV from quarantining Bazel-shipped binaries.","Do not prune the output base mid-build."],"tags":["windows","launcher","file-io","ifstream","build-tool"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}