quarkusio/quarkus · error · CodeGenException

Failed to create a wrapper script for quarkus-grpc plugin

Error message

Failed to create a wrapper script for quarkus-grpc plugin

What it means

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.

Source

Thrown at extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java:596

        }

        if (OS.current() != OS.WINDOWS) {
            return writeScript(buildDir, pluginPath, "#!/bin/sh\n", ".sh");
        } else {
            return writeScript(buildDir, pluginPath, "@echo off\r\n", ".cmd");
        }
    }

    private static Path writeScript(Path buildDir, Path pluginPath, String shebang, String suffix) throws CodeGenException {
        Path script;
        try {
            script = Files.createTempFile(buildDir, "quarkus-grpc", suffix);
            try (BufferedWriter writer = Files.newBufferedWriter(script)) {
                writer.write(shebang);
                writePluginExeCmd(pluginPath, writer);
            }
        } catch (IOException e) {
            throw new CodeGenException("Failed to create a wrapper script for quarkus-grpc plugin", e);
        }
        if (!script.toFile().setExecutable(true)) {
            throw new CodeGenFailureException("failed to set file: " + script + " executable. Protoc invocation may fail");
        }
        return script;
    }

    private static void writePluginExeCmd(Path pluginPath, BufferedWriter writer) throws IOException {
        writer.write("\"" + io.smallrye.common.process.ProcessUtil.pathOfJava().toString() + "\" -cp \"" +
                pluginPath.toAbsolutePath() + "\" " + quarkusProtocPluginMain);
        writer.newLine();
    }

    private static boolean containsQuarkusKotlin(Collection<ResolvedDependency> dependencies) {
        return dependencies.stream().anyMatch(new Predicate<ResolvedDependency>() {
            @Override
            public boolean test(ResolvedDependency rd) {
                return rd.getGroupId().equalsIgnoreCase("io.quarkus")

View on GitHub (pinned to e1c734241f)

Solutions

  1. Ensure the build output directory (target/) is writable and has free disk space
  2. Run mvn clean / gradle clean and rebuild to remove stale state
  3. Shorten the project path on Windows or enable long-path support
  4. Avoid running parallel builds that clean the same target directory concurrently

Example fix

# before: read-only workspace
ci: ./mvnw clean verify  # target/ mounted ro
# after: use a writable build dir
mvn -Dproject.build.directory=/tmp/build clean verify
Defensive patterns

Strategy: validation

Validate before calling

if (!Files.isWritable(buildDir) || Files.getFileStore(buildDir).getUsableSpace() < 64 * 1024 * 1024) {
    throw new IllegalStateException("Build dir not writable or low on disk: " + buildDir);
}

Try / catch

try {
    build.run();
} catch (CodeGenException e) {
    if (e.getMessage().contains("Failed to create a wrapper script")) {
        exec("mvn clean");
        ensureWritableAndSpace(buildDir);
        build.run();
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/30648df9216e617d. Report an issue: GitHub.