{"record":{"id":"30648df9216e617d","repo":"quarkusio/quarkus","slug":"failed-to-create-a-wrapper-script-for-quarkus-grpc","errorCode":null,"errorMessage":"Failed to create a wrapper script for quarkus-grpc plugin","messagePattern":"Failed to create a wrapper script for quarkus-grpc plugin","errorType":"exception","errorClass":"CodeGenException","httpStatus":null,"severity":"error","filePath":"extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java","lineNumber":596,"sourceCode":"        }\n\n        if (OS.current() != OS.WINDOWS) {\n            return writeScript(buildDir, pluginPath, \"#!/bin/sh\\n\", \".sh\");\n        } else {\n            return writeScript(buildDir, pluginPath, \"@echo off\\r\\n\", \".cmd\");\n        }\n    }\n\n    private static Path writeScript(Path buildDir, Path pluginPath, String shebang, String suffix) throws CodeGenException {\n        Path script;\n        try {\n            script = Files.createTempFile(buildDir, \"quarkus-grpc\", suffix);\n            try (BufferedWriter writer = Files.newBufferedWriter(script)) {\n                writer.write(shebang);\n                writePluginExeCmd(pluginPath, writer);\n            }\n        } catch (IOException e) {\n            throw new CodeGenException(\"Failed to create a wrapper script for quarkus-grpc plugin\", e);\n        }\n        if (!script.toFile().setExecutable(true)) {\n            throw new CodeGenFailureException(\"failed to set file: \" + script + \" executable. Protoc invocation may fail\");\n        }\n        return script;\n    }\n\n    private static void writePluginExeCmd(Path pluginPath, BufferedWriter writer) throws IOException {\n        writer.write(\"\\\"\" + io.smallrye.common.process.ProcessUtil.pathOfJava().toString() + \"\\\" -cp \\\"\" +\n                pluginPath.toAbsolutePath() + \"\\\" \" + quarkusProtocPluginMain);\n        writer.newLine();\n    }\n\n    private static boolean containsQuarkusKotlin(Collection<ResolvedDependency> dependencies) {\n        return dependencies.stream().anyMatch(new Predicate<ResolvedDependency>() {\n            @Override\n            public boolean test(ResolvedDependency rd) {\n                return rd.getGroupId().equalsIgnoreCase(\"io.quarkus\")","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java#L578-L614","documentation":"To run the Quarkus protoc plugin, writeScript creates a temporary wrapper file in the build directory, writes the shebang and the java -cp invocation, and wraps any IOException from temp-file creation or writing in this CodeGenException. The build's code-gen phase then fails.","triggerScenarios":"Code generation where a temp file cannot be created or written under the build directory: read-only build dir, disk full, path too long on Windows, or the directory removed mid-build.","commonSituations":"Read-only CI workspaces; full disks; Windows MAX_PATH limits from deep project paths; parallel builds that clean target/ while another build writes scripts; restrictive umask or container user mismatch.","solutions":["Ensure the build output directory (target/) is writable and has free disk space","Run mvn clean / gradle clean and rebuild to remove stale state","Shorten the project path on Windows or enable long-path support","Avoid running parallel builds that clean the same target directory concurrently"],"exampleFix":"# before: read-only workspace\nci: ./mvnw clean verify  # target/ mounted ro\n# after: use a writable build dir\nmvn -Dproject.build.directory=/tmp/build clean verify","handlingStrategy":"validation","validationCode":"if (!Files.isWritable(buildDir) || Files.getFileStore(buildDir).getUsableSpace() < 64 * 1024 * 1024) {\n    throw new IllegalStateException(\"Build dir not writable or low on disk: \" + buildDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    build.run();\n} catch (CodeGenException e) {\n    if (e.getMessage().contains(\"Failed to create a wrapper script\")) {\n        exec(\"mvn clean\");\n        ensureWritableAndSpace(buildDir);\n        build.run();\n    }\n}","preventionTips":["Keep the build output directory writable for the build user with free disk space","Avoid concurrent builds that clean the same target directory","Keep project paths short on Windows or enable long-path support","On CI, mount a writable workspace volume for build output"],"tags":["io","filesystem","grpc","codegen"],"backgroundTag":"file-write-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"}