{"record":{"id":"49342fa6b269c3d5","repo":"junit-team/junit5","slug":"failed-to-start-process","errorCode":null,"errorMessage":"Failed to start process","messagePattern":"Failed to start process","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"junit-platform-reporting/src/main/java/org/junit/platform/reporting/open/xml/GitInfoCollector.java","lineNumber":171,"sourceCode":"\t\t\tcatch (IOException ignore) {\n\t\t\t\treturn Optional.empty();\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tprocess.destroyForcibly();\n\t\t\t}\n\t\t}\n\n\t\tprivate static BufferedReader newBufferedReader(InputStream stream) {\n\t\t\treturn new BufferedReader(new InputStreamReader(stream, Charset.defaultCharset()));\n\t\t}\n\n\t\tprivate Process startProcess(String[] command) {\n\t\t\tProcess process;\n\t\t\ttry {\n\t\t\t\tprocess = new ProcessBuilder().directory(workingDir.toFile()).command(command).start();\n\t\t\t}\n\t\t\tcatch (IOException e) {\n\t\t\t\tthrow new UncheckedIOException(\"Failed to start process\", e);\n\t\t\t}\n\t\t\treturn process;\n\t\t}\n\n\t\tprivate static void readAllChars(Reader reader, BiConsumer<char[], Integer> consumer) throws IOException {\n\t\t\tchar[] buffer = new char[1024];\n\t\t\tint numChars;\n\t\t\twhile ((numChars = reader.read(buffer)) != -1) {\n\t\t\t\tconsumer.accept(buffer, numChars);\n\t\t\t}\n\t\t}\n\n\t\tprivate static String trimAtEnd(StringBuilder value) {\n\t\t\tint endIndex = value.length();\n\t\t\tfor (int i = value.length() - 1; i >= 0; i--) {\n\t\t\t\tif (Character.isWhitespace(value.charAt(i))) {\n\t\t\t\t\tendIndex--;\n\t\t\t\t\tbreak;","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-reporting/src/main/java/org/junit/platform/reporting/open/xml/GitInfoCollector.java#L153-L189","documentation":"Thrown as an UncheckedIOException by GitInfoCollector.ProcessExecutor.startProcess() when ProcessBuilder.start() fails to spawn the git child process. Note: startProcess is called OUTSIDE exec()'s try block, so this exception propagates even during the initial 'git --version' availability probe — it is not swallowed by exec()'s 'catch (IOException ignore)'. It ultimately surfaces wrapped inside error 145 ('Failed to initialize XML events writer'). GitInfoCollector is a package-private interface invoked only when junit.platform.reporting.open.xml.git.enabled is true.","triggerScenarios":"Enabling junit.platform.reporting.open.xml.git.enabled=true on a machine where the git binary is not installed or not on the PATH; the OS denying fork()/exec() due to pid or file-descriptor limits (cgroup-constrained containers); workingDir.toFile() returning null because the configured working dir is not a directory; the git binary disappearing between the version probe and a later command.","commonSituations":"Minimal Docker/Alpine CI images that omit git; distroless JVM images; sandboxes (sshd chroot, macOS sandbox) that block process spawning; ulimit -u/-n hit on a busy build agent; the working directory was deleted between the listener constructor (Path.of('.').toAbsolutePath()) and git collection.","solutions":["Disable git metadata collection: -Djunit.platform.reporting.open.xml.git.enabled=false (the default).","Install git in the CI/container image and ensure it is on the PATH of the JVM process.","Raise process/file-descriptor limits (ulimit -u, ulimit -n) on the build agent.","Confirm the listener's working directory still exists at testPlanExecutionStarted time."],"exampleFix":"// before\n-Djunit.platform.reporting.open.xml.git.enabled=true\n\n// after\n-Djunit.platform.reporting.open.xml.git.enabled=false","handlingStrategy":"fallback","validationCode":"// Only enable git collection if git is actually runnable on this host.\nboolean gitEnabled = Boolean.getBoolean(\n    \"junit.platform.reporting.open.xml.git.enabled\");\nif (gitEnabled) {\n    try {\n        Process p = new ProcessBuilder(\"git\", \"--version\").start();\n        boolean ok = p.waitFor(5, TimeUnit.SECONDS) && p.exitValue() == 0;\n        p.destroyForcibly();\n        if (!ok) {\n            System.clearProperty(\"junit.platform.reporting.open.xml.git.enabled\");\n        }\n    } catch (IOException | InterruptedException e) {\n        System.clearProperty(\"junit.platform.reporting.open.xml.git.enabled\");\n    }\n}","typeGuard":null,"tryCatchPattern":"// Users do not call GitInfoCollector directly (package-private). It surfaces wrapped\n// as JUnitException(\"Failed to initialize XML events writer\"). Catch at the launcher level:\ntry {\n    launcher.execute(request);\n} catch (JUnitException e) {\n    Throwable c = e.getCause();\n    if (c instanceof UncheckedIOException uio\n            && uio.getMessage().equals(\"Failed to start process\")) {\n        // Git unavailable in this environment; disable and retry, or report and skip.\n    }\n}","preventionTips":["Default junit.platform.reporting.open.xml.git.enabled to false in minimal containers.","Install git in CI images and verify 'git --version' runs as the build user before enabling.","Raise ulimit -u / ulimit -n on busy build agents to avoid fork failures.","Confirm the listener's working directory exists at testPlanExecutionStarted time."],"tags":["process","git","io","reporting","ci","configuration"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}