bazelbuild/bazel · error
prefix msg "\n"
Error message
prefix msg "\n"
What it means
On Windows, singlejar's diag.h implements its diagnostics (diag_err, diag_errx, diag_warn, diag_warnx) as macros that fprintf 'prefix + msg + newline' to stderr; the _diag_msgx variants then call ::ExitProcess(exit_value), terminating the zip creation tool immediately. The message template here is the shared body that stamps 'ERROR: ' or 'WARNING: ' in front of every singlejar diagnostic on Windows.
Source
Thrown at src/tools/singlejar/diag.h:41
defined(__OpenBSD__)
#include <err.h>
#define diag_err(...) err(__VA_ARGS__)
#define diag_errx(...) errx(__VA_ARGS__)
#define diag_warn(...) warn(__VA_ARGS__)
#define diag_warnx(...) warnx(__VA_ARGS__)
#elif defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <stdio.h>
#include <string.h>
#include <windows.h>
#define _diag_msg(prefix, msg, ...) \
{ \
fprintf(stderr, prefix msg "\n", ##__VA_ARGS__); \
}
#define _diag_msgx(exit_value, prefix, msg, ...) \
{ \
_diag_msg(prefix, msg, ##__VA_ARGS__); \
::ExitProcess(exit_value); \
}
#define diag_err(exit_value, fmt, ...) \
_diag_msgx(exit_value, "ERROR: ", fmt, ##__VA_ARGS__)
#define diag_errx(exit_value, fmt, ...) \
_diag_msgx(exit_value, "ERROR: ", fmt, ##__VA_ARGS__)
#define diag_warn(fmt, ...) _diag_msg("WARNING: ", fmt, ##__VA_ARGS__)
#define diag_warnx(fmt, ...) _diag_msg("WARNING: ", fmt, ##__VA_ARGS__)
#else
#error Unknown platform
#endif
#endif // BAZEL_SRC_TOOLS_SINGLEJAR_DIAG_H_View on GitHub (pinned to e6e199d060)
Solutions
- Check whether the output jar named in the preceding message is locked/read-only; close editors and rerun.
- Rerun the failing action with --subcommands to capture the exact singlejar invocation and run it manually to see the full diagnostic.
- Shorten output paths (enable Windows long-path support or move the workspace closer to the drive root).
- Verify free disk space on the output volume.
- If entries are reported duplicated, check the srcs of the java_singlejar/proto rule for the same file listed twice.
Defensive patterns
Strategy: validation
Validate before calling
// before singlejar runs, clear Windows file-lock obstacles on the output
// (pseudo) if exists(output) { clear_readonly(output); fail if locked }
std::error_code ec;
auto st = std::filesystem::status(out_path, ec);
if (!ec && exists(st)) {
std::filesystem::permissions(out_path, std::filesystem::perms::owner_write, std::filesystem::perm_options::add, ec);
if (ec) return error("output not writable: " + out_path.string());
} Prevention
- Exclude bazel-out from antivirus real-time scanning on Windows build agents.
- Do not keep generated jars open in editors while rebuilding.
- Deduplicate srcs in java_singlejar rules so entry-collision errors cannot fire.
- Watch free disk space; singlejar diagnostics often follow ENOSPC.
When it happens
Trigger: Calling singlejar (via Bazel's java_singlejar or proto bundling actions) on Windows when zip entry insertion fails, output file cannot be written, entry names collide, or the output zip already exists read-only; each failure path formats its message through _diag_msg before ExitProcess for the err variants.
Common situations: Output .jar marked read-only or locked by another process (VS, antivirus); path length beyond MAX_PATH; duplicate entry names when merging jars; disk full on the output drive during a Windows build.
Related errors
- Not a log level: " + input
- __FILE__ ":" S__LINE__ ": \"" __VA_ARGS__
- Could not seek to end of file (%s)
- Waiting for previous Bazel server's log file to close (waite
- Cannot write PID file %s
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/4ea3cc8917457db0.
Report an issue: GitHub.