NationalSecurityAgency/ghidra · error · IllegalArgumentException

Data directory {} does not exist

Error message

Data directory {} does not exist

What it means

Thrown by scanDataDirectory() when the provided path exists but File.isDirectory() is false — the path is missing, is a regular file, or is a broken symlink. BSim treats the data directory as the PostgreSQL cluster root and requires it to be a real directory.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:952

			new File(dataDirectory, "server.key"));
	}

	/**
	 * Scan the PostgreSQL data directory from the command-line
	 * Make sure the directory exists and establish the File object -dataDirectory-
	 * @param params are the command-line arguments
	 * @param slot is the position to retrieve the data directory argument
	 * @throws IllegalArgumentException if the data directory is invalid
	 * @throws IOException if the canonical file cannot be retrieved
	 */
	private void scanDataDirectory(String[] params, int slot)
			throws IllegalArgumentException, IOException {
		if (params.length <= slot) {
			throw new IllegalArgumentException("Missing data directory");
		}
		dataDirectory = new File(params[slot]);
		if (!dataDirectory.isDirectory()) {
			throw new IllegalArgumentException(
				"Data directory " + dataDirectory.getAbsolutePath() + " does not exist");
		}
		dataDirectory = dataDirectory.getCanonicalFile();
	}

	/**
	 * Scan the username from the command-line
	 * @param params are the command-line arguments
	 * @param slot is the position to retrieve the username argument
	 * @throws IllegalArgumentException if the user name is not in the given params
	 */
	private void scanUsername(String[] params, int slot) throws IllegalArgumentException {
		if (params.length <= slot) {
			throw new IllegalArgumentException("Missing username");
		}
		specifiedUserName = params[slot];
	}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Create the directory first: `mkdir -p <dataDir>`.
  2. Use an absolute path to avoid cwd ambiguity.
  3. Point at the cluster root (the dir containing postgresql.conf), not a file inside it.
  4. Verify with `ls -ld <dataDir>` that it is a directory.

Example fix

// before
bsim_ctl start /var/bsim/missing
// after
mkdir -p /var/bsim/data && bsim_ctl start /var/bsim/data
Defensive patterns

Strategy: validation

Validate before calling

File d = new File(dataDirPath);
if (!d.isDirectory()) {
    throw new IllegalArgumentException(
        "Data directory does not exist or is not a directory: " + d.getAbsolutePath());
}

Type guard

public boolean isExistingDataDir(File d) {
    return d != null && d.isDirectory();
}

Try / catch

try {
    bsimControl.exec(args);
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Data directory")
        && e.getMessage().endsWith("does not exist")) {
        throw new UserFacingException("Create the data dir first: mkdir -p " + dataDirPath, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Passing a non-existent or file path as the data directory: `bsim_ctl start /path/that/does/not/exist` or pointing at a file.

Common situations: Typo in the directory path; relative path resolved from the wrong cwd; directory not yet created; path points at a file (e.g. postgresql.conf) instead of the cluster root.

Related errors


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