{"record":{"id":"b39cfd3edc047560","repo":"elastic/elasticsearch","slug":"process-s-s-finished-with-non-zero-exit-value","errorCode":null,"errorMessage":"Process '%s %s' finished with non-zero exit value %d","messagePattern":"Process '(.+?) (.+?)' finished with non-zero exit value (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/LoggedExec.java","lineNumber":186,"sourceCode":"                execSpec.setStandardInput(new ByteArrayInputStream(getStandardInput().get().getBytes(StandardCharsets.UTF_8)));\n            }\n        });\n        int exitValue = execResult.getExitValue();\n\n        if (exitValue == 0 && getCaptureOutput().get()) {\n            output = byteStreamToString(out);\n        }\n        if (getLogger().isInfoEnabled() == false) {\n            if (exitValue != 0) {\n                try {\n                    if (getIndentingConsoleOutput().isPresent() == false) {\n                        getLogger().error(\"Output for \" + getExecutable().get() + \":\");\n                    }\n                    outputLogger.accept(getLogger());\n                } catch (Exception e) {\n                    throw new GradleException(\"Failed to read exec output\", e);\n                }\n                throw new GradleException(\n                    String.format(\"Process '%s %s' finished with non-zero exit value %d\", getExecutable().get(), getArgs().get(), exitValue)\n                );\n            }\n        }\n\n    }\n\n    private String byteStreamToString(OutputStream out) {\n        return ((ByteArrayOutputStream) out).toString(StandardCharsets.UTF_8);\n    }\n\n    public static ExecResult exec(ExecOperations execOperations, Action<ExecSpec> action) {\n        return genericExec(execOperations::exec, action);\n    }\n\n    public static ExecResult javaexec(ExecOperations project, Action<JavaExecSpec> action) {\n        return genericExec(project::javaexec, action);\n    }","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/LoggedExec.java#L168-L204","documentation":"LoggedExec.run() throws this after a process exits with non-zero status, but only when the logger is NOT at info level (the info-level path lets Gradle's own exec error handling surface). The task first dumps the captured stdout/stderr via outputLogger, then throws this GradleException with the executable, args, and exit code so the build fails with actionable context.","triggerScenarios":"Any LoggedExec task whose executed command returns a non-zero exit code while the build logger is above info level. The message includes the executable path, the args list, and the numeric exit value.","commonSituations":"A wrapped native tool (e.g., a code generator, formatter, or build helper) failing; missing executable on PATH; incorrect arguments passed via commandLine() or args(); the underlying command genuinely fails (test failures, missing input files).","solutions":["Read the 'Output for <executable>:' block logged just before this exception — it contains the process's stderr/stdout explaining the real failure.","Re-run with --info to get Gradle's native exec error with full streaming output.","Verify the executable path and args via commandLine()/args(); check the tool exists on PATH and is executable.","If the failure is expected in some contexts, set ignoreExitValue via a custom subclass (LoggedExec hardcodes setIgnoreExitValue(true) internally, so you must handle exitValue yourself in a subclass)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the command exists and args are correct before execution\nFile exe = new File(loggedExec.getExecutable().get());\nif (!exe.exists() && !onPath(exe.getName())) throw new IllegalStateException(\"Missing executable: \" + exe);","typeGuard":null,"tryCatchPattern":"try { task.exec(); } catch (GradleException e) { /* message contains executable, args, exit code — surface to build failure */ throw e; }","preventionTips":["Verify the executable path and args at configuration time when they come from dynamic sources.","Run with --info to get streaming process output for diagnosis.","Read the 'Output for <executable>:' block logged just before the exception."],"tags":["gradle","build-tools","exec","process-failure"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}