quarkusio/quarkus · error · RuntimeException

Unable to setup environment for generating Kubernetes resour

Error message

Unable to setup environment for generating Kubernetes resources

What it means

During the Kubernetes resource generation build step, Quarkus creates a temporary working directory (Files.createTempDirectory) to hold generated manifests. If the filesystem cannot provide a temp directory (IOException), the build aborts with this RuntimeException.

Source

Thrown at extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java:125

            List<ConfiguratorBuildItem> configurators,
            List<ConfigurationSupplierBuildItem> configurationSuppliers,
            List<DecoratorBuildItem> decorators,
            BuildProducer<DekorateOutputBuildItem> dekorateSessionProducer,
            Optional<CustomProjectRootBuildItem> customProjectRoot,
            Optional<CustomKubernetesOutputDirBuildItem> customOutputDir,
            BuildProducer<GeneratedFileSystemResourceBuildItem> generatedResourceProducer,
            BuildProducer<GeneratedKubernetesResourceBuildItem> generatedKubernetesResourceProducer,
            BuildProducer<KubernetesOutputDirectoryBuildItem> outputDirectoryBuildItemBuildProducer) {

        List<ConfiguratorBuildItem> allConfigurators = new ArrayList<>(configurators);
        List<ConfigurationSupplierBuildItem> allConfigurationSuppliers = new ArrayList<>(configurationSuppliers);
        List<DecoratorBuildItem> allDecorators = new ArrayList<>(decorators);

        final Path root;
        try {
            root = Files.createTempDirectory("quarkus-kubernetes");
        } catch (IOException e) {
            throw new RuntimeException("Unable to setup environment for generating Kubernetes resources", e);
        }

        Map<String, Object> config = KubernetesConfigUtil.toMap(kubernetesConfig, openshiftConfig, knativeConfig);
        Set<String> deploymentTargets = kubernetesDeploymentTargets.getEntriesSortedByPriority().stream()
                .map(DeploymentTargetEntry::getName)
                .collect(Collectors.toSet());

        Path artifactPath = getRunner(outputTarget, packageConfig);

        try {
            // by passing false to SimpleFileWriter, we ensure that no files are actually written during this phase
            Optional<Project> optionalProject = KubernetesCommonHelper.createProject(applicationInfo, customProjectRoot,
                    artifactPath);
            optionalProject.ifPresent(project -> {
                Set<String> targets = new HashSet<>();
                targets.add(COMMON);
                targets.addAll(deploymentTargets);
                final Map<String, String> generatedResourcesMap;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Free disk space on the volume backing the temp directory.
  2. Ensure /tmp (or java.io.tmpdir) exists and is writable by the build user (e.g. add a writable emptyDir tmp mount in the build container).
  3. Set -Djava.io.tmpdir=/some/writable/dir for the Maven/Gradle build process.

Example fix

// before
MAVEN_OPTS="-Xmx4g" ./mvnw package // /tmp full or read-only
// after
mkdir -p /workspace/tmp && MAVEN_OPTS="-Xmx4g -Djava.io.tmpdir=/workspace/tmp" ./mvnw package
Defensive patterns

Strategy: validation

Validate before calling

// Check temp dir writability before building
Path tmp = Path.of(System.getProperty("java.io.tmpdir"));
if (!Files.isDirectory(tmp) || !Files.isWritable(tmp)) {
    throw new IllegalStateException("Temp dir not writable: " + tmp + " — set -Djava.io.tmpdir");
}
Files.createTempFile("quarkus-preflight", ".tmp"); // probe write

Try / catch

try {
    ./mvnw package
} — outside Java: preflight the build container:
if [ ! -w "${TMPDIR:-/tmp}" ]; then export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -Djava.io.tmpdir=/workspace/tmp"; fi

Prevention

When it happens

Trigger: Files.createTempDirectory("quarkus-kubernetes") throws IOException during the kubernetes build step — e.g. the java.io.tmpdir is read-only, full, or missing.

Common situations: Disk-full CI runners or containers with read-only /tmp; restrictive TMPDIR/java.io.tmpdir permissions; containers running with a read-only root filesystem and no writable tmp mount.

Related errors


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