NationalSecurityAgency/ghidra · error · IOException

Unable to create temp directory: {dir.getAbsolutePath()}

Error message

Unable to create temp directory: {dir.getAbsolutePath()}

What it means

Thrown by establishTemporaryDirectory when dir.mkdir() returns false, meaning the operating system refused to create the directory. This is a filesystem-level failure — typically permissions, a parent that doesn't exist, or a name collision. Note mkdir() only creates one level; it does not create parents.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BulkSignatures.java:1029

		}
	}

	protected File establishTemporaryDirectory(String xmldir) throws IOException {
		File dir;
		if (xmldir == null) {
			File tmpDir = Application.getUserTempDirectory();
			if (tmpDir == null) {
				throw new IOException("Could not find temporary directory");
			}
			dir = new File(tmpDir, "bulkinsert_xml");
			deleteTemporaryDirectory(dir);
		}
		else {
			dir = new File(xmldir);
		}
		if (dir.exists() == false) {
			if (dir.mkdir() == false) {
				throw new IOException("Unable to create temp directory: " + dir.getAbsolutePath());
			}
		}
		else if (dir.isDirectory() == false) {
			throw new IOException(dir.getAbsolutePath() + ": is not a directory");
		}
		dir = dir.getCanonicalFile();
		return dir;
	}

	private void deleteTemporaryDirectory(File tempDir) throws IOException {
		if (!tempDir.exists()) {
			return;
		}
		File[] listFiles = tempDir.listFiles();
		if (listFiles == null) {
			throw new IOException(
				"Could not list files in temp directory: " + tempDir.getAbsolutePath());
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Check write permissions on the parent directory.
  2. Use mkdirs() instead of mkdir() if parent directories may be missing.
  3. Verify the path doesn't already contain a regular file with the same name.
  4. Check available disk space on the target volume.

Example fix

// before
if (dir.mkdir() == false) {
    throw new IOException("Unable to create temp directory: " + dir.getAbsolutePath());
}

// after — create parents, report cause
if (!dir.exists() && !dir.mkdirs()) {
    throw new IOException("Unable to create temp directory: " + dir.getAbsolutePath() +
        " (parent exists: " + dir.getParentFile() != null &&
        dir.getParentFile().exists() + ", writable: " +
        (dir.getParentFile() != null && dir.getParentFile().canWrite()) + ")");
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify the parent directory is writable before attempting mkdir
File parent = dir.getParentFile();
if (parent != null && !parent.exists()) {
    parent.mkdirs(); // create missing parents
}
if (parent != null && !parent.canWrite()) {
    throw new IllegalStateException(
        "Cannot write to parent directory: " + parent.getAbsolutePath());
}

Type guard

public static boolean canCreateDirectory(File dir) {
    File parent = dir.getParentFile();
    return dir != null && parent != null &&
        (dir.exists() ? dir.isDirectory() : parent.canWrite());
}

Try / catch

try {
    File dir = bulk.establishTemporaryDirectory(xmldir);
} catch (IOException e) {
    if (e.getMessage().contains("Unable to create temp directory")) {
        // Try a different location
        File dir = bulk.establishTemporaryDirectory(System.getProperty("user.home") + "/.bsim_tmp");
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: The target directory path has a parent that doesn't exist (mkdir doesn't create parents); the parent directory is not writable by the current user; a file with the same name already exists at that path; disk is full or the filesystem is read-only.

Common situations: Running BSim tools as a user without write access to the parent directory; the temp directory path derived from a misconfigured setting; a previous run left a file (not directory) at the expected path; running on a read-only filesystem or full disk.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/4015135f5c7ccf13. Report an issue: GitHub.