bazelbuild/bazel · error
Failed to open " STRING_FORMAT ": %s\n
Error message
Failed to open " STRING_FORMAT ": %s\n
What it means
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.
Source
Thrown at src/tools/launcher/launcher_maker.cc:74
#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;
}
dst << src.rdbuf();
std::ifstream info_file(info_params.c_str());
if (!info_file.good()) {
fprintf(stderr, "Failed to open " STRING_FORMAT ": %s\n",
info_params.c_str(), strerror(errno));
return 1;
}
int64_t bytes = 0;View on GitHub (pinned to e6e199d060)
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.
Defensive patterns
Strategy: validation
Validate before calling
// verify the launcher input exists and is readable before running the action
struct stat st;
if (stat(launcher_path.c_str(), &st) != 0 || !(st.st_mode & S_IREAD)) {
fprintf(stderr, "missing/unreadable launcher: %s\n", launcher_path.c_str());
return 1;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Custom rules passing a wrong launcher location; antivirus quarantining the launcher exe; output base pruned mid-build by an external cleaner.
Related errors
- Failed to make absolute path for %s: %s\n
- Failed to create " STRING_FORMAT ": %s\n
- Expected 3 arguments, got %d\n
- prefix msg "\n"
- Could not seek to end of file (%s)
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/40f0d00009649dd6.
Report an issue: GitHub.