NationalSecurityAgency/ghidra · error · IOException

{dir.getAbsolutePath()}: is not a directory

Error message

{dir.getAbsolutePath()}: is not a directory

What it means

Thrown by establishTemporaryDirectory when the target path exists (dir.exists() is true) but is not a directory (dir.isDirectory() is false). This means a regular file occupies the path that should be a directory. The code cannot proceed because it needs to write files into this directory.

Source

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

		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());
		}
		for (File listFile : listFiles) {
			if (!listFile.delete()) {
				throw new IOException(
					"Unable to delete temporary file: " + listFile.getAbsolutePath());

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Remove or rename the file at the conflicting path.
  2. Change the xmldir parameter to point to a valid directory location.
  3. If using the default temp path, remove the stray file from the temp directory manually.
  4. Investigate what created the file — it may indicate a bug in a prior step.

Example fix

// before
else if (dir.isDirectory() == false) {
    throw new IOException(dir.getAbsolutePath() + ": is not a directory");
}

// after — distinguish file vs symlink vs other
else if (dir.isDirectory() == false) {
    throw new IOException(dir.getAbsolutePath() + ": exists as a " +
        (dir.isFile() ? "regular file" : "non-directory entry") +
        "; remove it or specify a different xmldir");
}
Defensive patterns

Strategy: validation

Validate before calling

// Check that the path is not occupied by a non-directory entry
if (dir.exists() && !dir.isDirectory()) {
    throw new IllegalStateException(
        "Path occupied by non-directory entry: " + dir.getAbsolutePath() +
        ". Remove it or use a different path.");
}

Type guard

public static boolean isPathAvailableForDirectory(File dir) {
    return !dir.exists() || dir.isDirectory();
}

Try / catch

try {
    File dir = bulk.establishTemporaryDirectory(xmldir);
} catch (IOException e) {
    if (e.getMessage().contains("is not a directory")) {
        // The path is a file — try removing it or use alternate location
        File conflict = new File(xmldir);
        if (conflict.isFile()) {
            conflict.delete();
        }
        File dir = bulk.establishTemporaryDirectory(xmldir);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: A previous process or manual operation created a regular file at the path where the code expects a directory. This is the else-if branch after the mkdir path, so the path already exists as something other than a directory.

Common situations: A prior failed run left a file named 'bulkinsert_xml' instead of a directory; a user accidentally created a file with the same name; the xmldir parameter points to a path occupied by a file; a symlink pointing to a file rather than a directory.

Related errors


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