{"record":{"id":"49a770ebcd3e63f3","repo":"quarkusio/quarkus","slug":"unable-to-invoke-kotlin-compiler","errorCode":null,"errorMessage":"Unable to invoke Kotlin compiler. ","messagePattern":"Unable to invoke Kotlin compiler\\. ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinCompilationProvider.java","lineNumber":99,"sourceCode":"\n        compilerArguments.setDestination(context.getOutputDirectory().getAbsolutePath());\n        compilerArguments.setFreeArgs(filesToCompile.stream().map(File::getAbsolutePath).collect(Collectors.toList()));\n\n        final K2JVMCompiler compiler = new K2JVMCompiler();\n        final Collection<String> compilerOptions = context.getCompilerOptions(KOTLIN_PROVIDER_KEY);\n\n        if (compilerOptions != null && !compilerOptions.isEmpty()) {\n            compiler.parseArguments(compilerOptions.toArray(new String[0]), compilerArguments);\n        }\n\n        final SimpleKotlinCompilerMessageCollector messageCollector = new SimpleKotlinCompilerMessageCollector();\n        final ExitCode exitCode = compiler.exec(messageCollector, new Services.Builder().build(), compilerArguments);\n\n        if (exitCode != ExitCode.OK) {\n            final String errors = String.join(\"\\n\", messageCollector.getErrors());\n\n            if (exitCode != ExitCode.COMPILATION_ERROR) {\n                throw new RuntimeException(\"Unable to invoke Kotlin compiler. \" + errors);\n            } else if (messageCollector.hasErrors()) {\n                throw new RuntimeException(\"Compilation failed. \" + errors);\n            }\n        }\n    }\n\n    private static class SimpleKotlinCompilerMessageCollector implements MessageCollector {\n\n        private final List<String> errors = new ArrayList<>();\n\n        @Override\n        public void clear() {\n        }\n\n        @Override\n        public boolean hasErrors() {\n            return !errors.isEmpty();\n        }","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinCompilationProvider.java#L81-L117","documentation":"KotlinCompilationProvider.compile throws this RuntimeException when the Kotlin compiler execution returns an exit code other than OK or COMPILATION_ERROR — i.e. the compiler could not even run properly (crashed, OOM, bad toolchain), as opposed to ordinary compile errors in user code. Collected compiler errors are appended to the message.","triggerScenarios":"Building a Quarkus app with Kotlin sources where kotlinc's exec returns an abnormal exit code — e.g. incompatible kotlin-compiler version on the classpath vs. the Kotlin Gradle/Maven plugin, JVM crash or OutOfMemory during compilation, or corrupted Kotlin toolchain/daemon state.","commonSituations":"Kotlin stdlib/compiler version mismatches after upgrading the Quarkus BOM; build JVM with too little heap for the Kotlin compiler; Kotlin daemon crashes; mixing Kotlin plugin versions not aligned with the compiler embedding used by Quarkus.","solutions":["Read the appended compiler errors in the message for the root cause (often OOM or version conflict).","Align the Kotlin version: use the Kotlin version matching your Quarkus BOM (quarkus.platform.native/kotlin recommendations) in the Kotlin Maven/Gradle plugin and stdlib.","Increase build JVM memory (MAVEN_OPTS/gradle jvmargs, e.g. -Xmx2g or more) if the compiler is dying from OOM.","Stop stale Kotlin daemons (kill KotlinCompileDaemon processes) or run with kotlin.compiler.execution.strategy=in-process, then rebuild clean."],"exampleFix":"// before (mismatched versions)\n<artifact>kotlin-maven-plugin</artifact>\n<version>1.9.0</version> <!-- Quarkus BOM expects 2.0.x -->\n// after: use the version Quarkus recommends\n<kotlin.version>2.0.21</kotlin.version>\nexport MAVEN_OPTS=\"-Xmx3g\"","handlingStrategy":"try-catch","validationCode":"// pre-flight: verify kotlin compiler toolchain alignment before compiling\nString bomKotlin = \"2.0.21\"; // version from quarkus BOM\nString pluginKotlin = kotlinPluginVersion;\nif (!bomKotlin.equals(pluginKotlin))\n    log.warn(\"Kotlin version mismatch: plugin={}, expected={}\", pluginKotlin, bomKotlin);\nif (Runtime.getRuntime().maxMemory() < 2L * 1024 * 1024 * 1024)\n    log.warn(\"Low build JVM heap (-Xmx<2g); Kotlin compiler may fail\");","typeGuard":null,"tryCatchPattern":"try {\n    compilationProvider.compile(context);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to invoke Kotlin compiler\")) {\n        log.error(\"Kotlin compiler failed to run (not a compile error): check version alignment, heap, daemon\", e);\n    }\n    throw e;\n}","preventionTips":["Keep the Kotlin Maven/Gradle plugin and stdlib version aligned with the Quarkus BOM.","Give the build JVM ample heap (MAVEN_OPTS=-Xmx3g).","Kill stale Kotlin compile daemons before CI builds; consider in-process execution.","Read the appended compiler errors — they name the actual root cause (OOM, bad flag, etc.)."],"tags":["kotlin","build","compiler","maven"],"backgroundTag":"kotlin-compiler-invocation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}