{"record":{"id":"35d842cec96077ce","repo":"quarkusio/quarkus","slug":"failed-to-extract-proto-file-path-to-target","errorCode":null,"errorMessage":"Failed to extract proto file\" + path + \" to target: \" + outPath","messagePattern":"Failed to extract proto file\" \\+ path \\+ \" to target: \" \\+ outPath","errorType":"exception","errorClass":"GrpcCodeGenException","httpStatus":null,"severity":"error","filePath":"extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java","lineNumber":430,"sourceCode":"                        if (Files.isRegularFile(path) && path.getFileName().toString().endsWith(PROTO)) {\n                            String strippedPathStr = stripProtoPrefix(pathVisit.getResourceName());\n                            try {\n                                Files.createDirectories(protoOutputDir);\n                                protoDirectories.add(protoOutputDir.toString());\n                            } catch (IOException e) {\n                                throw new GrpcCodeGenException(\"Failed to create directory: \" + protoOutputDir, e);\n                            }\n                            Path outPath = protoOutputDir.resolve(strippedPathStr);\n                            try {\n                                Files.createDirectories(outPath.getParent());\n                                if (isDependency) {\n                                    copySanitizedProtoFile(artifact, path, outPath);\n                                } else {\n                                    Files.copy(path, outPath, StandardCopyOption.REPLACE_EXISTING);\n                                }\n                                protoFiles.add(outPath);\n                            } catch (IOException e) {\n                                throw new GrpcCodeGenException(\"Failed to extract proto file\" + path + \" to target: \"\n                                        + outPath, e);\n                            }\n                        }\n                    });\n        } catch (GrpcCodeGenException e) {\n            throw new CodeGenException(e.getMessage(), e);\n        }\n    }\n\n    private static String stripProtoPrefix(String relativePathStr) {\n        if (relativePathStr.startsWith(SRC_MAIN_PROTO_DIR)) {\n            return relativePathStr.substring(SRC_MAIN_PROTO_DIR.length());\n        }\n        if (relativePathStr.startsWith(SRC_TEST_PROTO_DIR)) {\n            return relativePathStr.substring(SRC_TEST_PROTO_DIR.length());\n        }\n        if (relativePathStr.startsWith(PROTO_DIR)) {\n            return relativePathStr.substring(PROTO_DIR.length());","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java#L412-L448","documentation":"After creating the destination directory, Quarkus gRPC codegen copies each .proto file from the scanned dependency artifact to the work directory (sanitizing dependency protos). If Files.copy or copySanitizedProtoFile throws an IOException, the build fails with this GrpcCodeGenException naming the source proto file and target path.","triggerScenarios":"Running quarkus:dev / mvn compile with grpc code generation where a dependency contains .proto files, and copying a proto fails due to missing permissions on the source or target, the source file disappearing mid-walk, or the target path colliding with a non-directory.","commonSituations":"Source JAR partially downloaded or locked by another process (Windows antivirus/indexer); target/ owned by another user; disk full; network-mounted workspace with flaky I/O; parallel builds racing over the same target directory.","solutions":["Run a clean build (mvn clean or gradle clean) to remove stale/partially copied protos in target","Verify the source JAR in the local Maven repository is intact (delete it and let Maven/Gradle re-download)","Check filesystem permissions on both the artifact JAR and the build output directory","Close processes locking files on Windows (antivirus, IDE indexing) or exclude the build dir from real-time scanning","Ensure disk space is available on the volume hosting the build directory"],"exampleFix":"// before: corrupted cached artifact\n~/.m2/repository/com/example/proto-deps/1.0/proto-deps-1.0.jar (truncated)\n// after: force re-download\nrm ~/.m2/repository/com/example/proto-deps/1.0/proto-deps-1.0.jar\nmvn clean compile","handlingStrategy":"validation","validationCode":"// verify the dependency JAR containing protos is readable before building\nPath jar = Paths.get(System.getProperty(\"user.home\"), \".m2/repository/com/example/proto-deps/1.0/proto-deps-1.0.jar\");\nif (!Files.isReadable(jar) || jar.size() == 0) throw new IllegalStateException(\"Artifact unreadable or corrupt: \" + jar);","typeGuard":null,"tryCatchPattern":"try {\n    mvnRunner.run(\"compile\");\n} catch (BuildFailure e) {\n    if (e.getMessage().contains(\"Failed to extract proto file\")) {\n        Files.deleteIfExists(cachedArtifact); // then rebuild to re-download\n    }\n}","preventionTips":["Keep target/ free of hand-edited files; always clean before debugging codegen","Exclude build dirs from antivirus real-time scanning on Windows","Check artifact integrity when a mirror/proxy is in play","Avoid parallel builds sharing the same target directory"],"tags":["io","filesystem","grpc","codegen"],"backgroundTag":"file-copy-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"}