{"record":{"id":"95f04763b3cef6c4","repo":"quarkusio/quarkus","slug":"failed-to-generate-java-files-from-proto-file-in","errorCode":null,"errorMessage":"Failed to generate java files from proto file in \" + inputDir.toAbsolutePath()","messagePattern":"Failed to generate java files from proto file in \" \\+ inputDir\\.toAbsolutePath\\(\\)","errorType":"exception","errorClass":"CodeGenException","httpStatus":null,"severity":"error","filePath":"extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java","lineNumber":219,"sourceCode":"                    ProcessBuilder<Void> pb = ProcessBuilder.newBuilder(command.get(0),\n                            command.subList(1, command.size()));\n                    // Tune the environment for compatibility with Java >24 without triggering warnings\n                    pb.modifyEnvironment(GrpcCodeGen::invocationEnvironmentTuning);\n                    // Set up a custom output handler to highlight only relevant errors\n                    pb.output().consumeLinesWith(100, this::outputConsumer);\n                    pb.error().consumeLinesWith(100, this::outputConsumer).logOnSuccess(false);\n                    pb.run();\n                } catch (Exception e) {\n                    throw new CodeGenException(\"Failed to generate Java classes from proto files: %s to %s with command %s\"\n                            .formatted(protoFiles, outDir.toAbsolutePath(), String.join(\" \", command)), e);\n                }\n                postprocessing(context, outDir);\n                log.info(\"Successfully finished generating and post-processing sources from proto files\");\n\n                return true;\n            }\n        } catch (IOException e) {\n            throw new CodeGenException(\n                    \"Failed to generate java files from proto file in \" + inputDir.toAbsolutePath(), e);\n        }\n\n        return false;\n    }\n\n    private static void invocationEnvironmentTuning(final Map<String, String> environment) {\n        //This specific environment variable is being picked up by the JVMs spawned by protoc:\n        final String key = \"JDK_JAVA_OPTIONS\";\n        String existingValue = environment.get(key);\n        if (existingValue == null || existingValue.isBlank()) {\n            existingValue = \"\";\n        }\n        StringBuilder sb = new StringBuilder();\n        //Each of these require custom logic to ensure we don't override an explicit user setting\n\n        if (!existingValue.contains(\"-Dsun.stdout.encoding=\")) {\n            //This one is always useful, especially on Java 17:","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java#L201-L237","documentation":"GrpcCodeGen.trigger wraps any IOException occurring during the proto-file setup/generation workflow into a CodeGenException naming the input directory. Unlike the protoc-execution error, this indicates a filesystem/IO problem before or around the generation step, not a proto compilation error.","triggerScenarios":"Building with the Quarkus gRPC code generator when the proto input directory cannot be read or the output directory cannot be created/written: missing src/main/proto directory handling paths, locked files, or disk/full-permission failures.","commonSituations":"Read-only working directories in CI; files locked by a running dev-mode process on Windows; disk quota exceeded; inputDir deleted by an aggressive clean rule while the build runs.","solutions":["Check the caused-by IOException for the exact file/path and OS reason","Verify src/main/proto exists with read permission and target/generated-sources is writable","Stop competing processes (dev mode, IDE watchers) locking the output dir, clean, and rebuild"],"exampleFix":"// before\n// CI running as user without write access to target/\nmvn verify // CodeGenException: Failed to generate java files from proto file in .../src/main/proto\n// after\n# grant write access or set a writable build output\nchmod -R u+w target && mvn verify","handlingStrategy":"validation","validationCode":"File protoDir = new File(\"src/main/proto\");\nif (!protoDir.canRead()) throw new IllegalStateException(\"Cannot read proto dir: \" + protoDir);\nFile out = new File(\"target/generated-sources\");\nif (out.exists() && !out.canWrite()) throw new IllegalStateException(\"Output dir not writable: \" + out);","typeGuard":null,"tryCatchPattern":"try {\n    mvn clean install;\n} catch (CodeGenException e) {\n    if (e.getCause() instanceof IOException ioe) {\n        System.err.println(\"Filesystem problem during codegen: \" + ioe.getMessage());\n    }\n}","preventionTips":["Run builds with a user that has write access to target/ and read access to src/main/proto","Avoid concurrent processes (dev mode, IDE watchers) locking target/ during builds","Check disk space/quota in CI before running codegen-heavy builds"],"tags":["grpc","codegen","io","build"],"backgroundTag":"codegen-io-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}