{"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/956246301e03d757539f7b76dd5a91f298637563/junit-platform-reporting/src/main/java/org/junit/platform/reporting/open/xml/GitInfoCollector.java#L153-L189","documentation":"Thrown by GitInfoCollector.ProcessExecutor.startProcess() as an UncheckedIOException when ProcessBuilder.start() raises IOException. Occurs when the 'git' executable (or whichever command) cannot be launched - typically git not on PATH, the working directory is invalid, or the OS refused process creation.","triggerScenarios":"OpenTestReportGeneratingListener with junit.platform.reporting.open.xml.git.enabled=true triggers GitInfoCollector.get(), which calls executor.exec('git', '--version'). startProcess() throws if git is not installed or the working directory does not exist. Note: the 'is git installed' probe itself throws rather than returning empty when start() fails.","commonSituations":"CI image without git installed. Working directory deleted/changed before report generation. Minimal Docker images (distroless) lacking git. PATH not propagated to the test JVM.","solutions":["Install git on the PATH of the environment running tests, or","Disable git info collection: set junit.platform.reporting.open.xml.git.enabled=false.","Ensure the JVM's working directory exists and is readable.","Verify the PATH environment variable is inherited by the test process."],"exampleFix":"# before (junit-platform.properties)\njunit.platform.reporting.open.xml.git.enabled = true\n# git missing -> UncheckedIOException\n\n# after\njunit.platform.reporting.open.xml.git.enabled = false","handlingStrategy":"validation","validationCode":"// Disable git collection when git is unavailable\nboolean gitPresent = Arrays.stream(System.getenv(\"PATH\").split(File.pathSeparator))\n    .anyMatch(p -> new File(p, \"git\").canExecute());\nif (!gitPresent) System.setProperty(\"junit.platform.reporting.open.xml.git.enabled\", \"false\");","typeGuard":"static boolean gitAvailable() {\n    try { new ProcessBuilder(\"git\",\"--version\").start().waitFor(); return true; }\n    catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n    GitInfoCollector.get(workingDir);\n} catch (UncheckedIOException e) {\n    // disable git reporting and continue\n}","preventionTips":["Install git in CI images that enable git reporting, or keep the property disabled.","Inherit PATH into the test JVM so ProcessBuilder can resolve 'git'.","For distroless images, set junit.platform.reporting.open.xml.git.enabled=false."],"tags":["git","process","io","reporting","junit-platform"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}