{"record":{"id":"5a0b542bcf4401da","repo":"bazelbuild/bazel","slug":"cannot-write-pid-file-s","errorCode":null,"errorMessage":"Cannot write PID file %s\n","messagePattern":"Cannot write PID file (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/main/cpp/blaze_util_windows.cc","lineNumber":731,"sourceCode":"  }\n\n  if (!ok) {\n    string err = GetLastErrorString();\n    BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR)\n        << \"ExecuteDaemon(\" << exe.AsPrintablePath() << \"): CreateProcess(\"\n        << cmdline.cmdline << \") failed: \" << err;\n  }\n\n  WriteProcessStartupTime(server_dir, processInfo.hProcess);\n\n  // Pass ownership of processInfo.hProcess\n  *server_startup = new ProcessHandleBlazeServerStartup(processInfo.hProcess);\n\n  string pid_string = blaze_util::ToString(processInfo.dwProcessId);\n  blaze_util::Path pid_file = server_dir.GetRelative(kServerPidFile);\n  if (!blaze_util::WriteFile(pid_string, pid_file)) {\n    // Not a lot we can do if this fails\n    fprintf(stderr, \"Cannot write PID file %s\\n\",\n            pid_file.AsPrintablePath().c_str());\n  }\n\n  // Don't close processInfo.hProcess here, it's now owned by the\n  // ProcessHandleBlazeServerStartup instance.\n  CloseHandle(processInfo.hThread);\n\n  return processInfo.dwProcessId;\n}\n\n// Run the given program in the current working directory, using the given\n// argument vector, wait for it to finish, then exit ourselves with the exitcode\n// of that program.\nATTRIBUTE_NORETURN static void ExecuteProgram(\n    const blaze_util::Path& exe,\n    const std::vector<std::wstring>& wargs_vector) {\n  CmdLine cmdline;\n  CreateCommandLine(&cmdline, blaze_util::Path(), wargs_vector);","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/cpp/blaze_util_windows.cc#L713-L749","documentation":"After the Bazel client spawns the server process on Windows, it writes the new server's PID to output_base/server/server.pid via blaze_util::WriteFile; if that write fails it only prints this warning and continues (the code comment notes 'Not a lot we can do'). Consequences are limited: tooling that reads the pid file (e.g. shutdown heuristics) may see a stale PID until the next successful write.","triggerScenarios":"server.pid or its directory is read-only or was deleted concurrently; the output base is on a full or quota-exceeded volume; antivirus/sync software transiently locks server.pid right after server start.","commonSituations":"Output base on a synced/network drive with delayed lock release; disk-full CI agents; users manually deleting parts of output_base while a server is starting.","solutions":["Treat it as non-fatal: the build still proceeds; verify with 'bazel info server_pid'.","Check free space and write permissions on the output_base/server directory.","Exclude the output base from antivirus/on-access scanners and sync clients.","Run 'bazel shutdown' and restart cleanly so the PID file is rewritten.","If server_pid queries return a stale value, remove server.pid manually while no server is running."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the output_base on a local writable volume with free space.","Do not delete parts of output_base while a server is starting.","If you script against server.pid, tolerate a missing/stale file (check process liveness).","Exclude output_base from sync clients that transiently lock server.pid."],"tags":["windows","server","pid-file","filesystem","non-fatal"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}