apache/pulsar · error · UncheckedIOException
Cannot create temp directory
Error message
Cannot create temp directory
What it means
LocalRunner.createNarExtractionTempDirectory calls Files.createTempDirectory to make a scratch directory for extracting NAR archives. If the filesystem cannot create the directory (no writable temp dir, missing TMPDIR target, disk full), the IOException is rethrown as an UncheckedIOException with this message. It surfaces during LocalRunner startup before any function instance runs.
Source
Thrown at pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java:287
}
});
}
private static String getPulsarDirectory(String directory) {
final Path directoryPath;
if (System.getenv("PULSAR_HOME") != null) {
directoryPath = Path.of(System.getenv("PULSAR_HOME"), directory);
} else {
directoryPath = Path.of(directory);
}
return directoryPath.toAbsolutePath().normalize().toString();
}
private static File createNarExtractionTempDirectory() {
try {
return Files.createTempDirectory("pulsar_localrunner_nars_").toFile();
} catch (IOException e) {
throw new UncheckedIOException("Cannot create temp directory", e);
}
}
@Override
public void close() throws Exception {
try {
stop();
} finally {
if (narExtractionDirectoryCreated != null) {
if (narExtractionDirectoryCreated.exists()) {
FileUtils.deleteFile(narExtractionDirectoryCreated, true);
}
}
}
}
@SuppressWarnings("deprecation")
public synchronized void stop() {View on GitHub (pinned to 820761864e)
Solutions
- Verify the java.io.tmpdir (or TMPDIR env) points to an existing writable directory; pass -Djava.io.tmpdir=/writable/path
- Free disk space or raise the quota on the volume backing temp storage
- Check permissions on the temp directory (chmod/chown or run as a user with write access)
- If /tmp is read-only, mount a writable emptyDir/tmpfs volume
Example fix
// before (container) // (no writable temp) // after // docker run -e TMPDIR=/tmp-work -v writable-vol:/tmp-work ...
Defensive patterns
Strategy: validation
Validate before calling
Path tmp = Path.of(System.getProperty("java.io.tmpdir", "/tmp"));
if (!Files.isDirectory(tmp) || !Files.isWritable(tmp)) {
throw new IllegalStateException("Temp dir not writable: " + tmp);
} Try / catch
try {
runner.start(true);
} catch (UncheckedIOException e) {
if (e.getMessage().contains("Cannot create temp directory")) {
// point java.io.tmpdir to a writable location and retry
}
} Prevention
- Ensure java.io.tmpdir/TMPDIR is writable in containers
- Mount a writable emptyDir/tmpfs when /tmp is read-only
- Monitor disk space on temp volumes
When it happens
Trigger: Calling LocalRunner.start with an archive-based (NAR) function when java.io.tmpdir points to a non-writable, non-existent, or full directory, or when the OS temp filesystem is exhausted.
Common situations: Containers run with read-only /tmp, TMPDIR pointing to a deleted directory, restrictive umask/permissions on the temp path, or disk quota exhaustion on Kubernetes nodes.
Related errors
- Failed to create base storage directory at ${storagePath}
- Could not open configuration file
- Interrupted when connecting to zookeeper server
- Failed to read decryption key from ${keyUri}
- ${dir} is not a directory
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/b342bfaa482ae0a3.
Report an issue: GitHub.