NationalSecurityAgency/ghidra · error · IllegalArgumentException

Missing data directory

Error message

Missing data directory

What it means

Thrown by scanDataDirectory(params, slot) when the command-line arguments are shorter than expected — the positional data-directory argument is absent. BSim needs the data directory path for virtually every subcommand (start/stop/status/adduser/dropuser/changeauth).

Source

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

		// Patch the configuration
		tuneConfig(configCopy, configFile, hbaCopy, hbaFile, serverConfigFile);
		System.out.println("Generating servers SSL certificate");
		generateSelfSignedCertificate(new File(dataDirectory, "server.crt"),
			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");

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Append the data directory path as the positional argument: `bsim_ctl <command> [options] <dataDir>`.
  2. Check the command usage/help for the expected argument order.
  3. Quote paths containing spaces.

Example fix

// before
bsim_ctl start
// after
bsim_ctl start /var/bsim/data
Defensive patterns

Strategy: validation

Validate before calling

// Validate the argument vector shape before delegating to BSimControlLaunchable.
if (args.length < expectedSlot + 1) {
    throw new IllegalArgumentException(
        "Missing required <dataDir> positional argument");
}

Type guard

public boolean hasDataDirArg(String[] args, int slot) {
    return args != null && args.length > slot && StringUtils.isNotBlank(args[slot]);
}

Try / catch

try {
    bsimControl.exec(args);
} catch (IllegalArgumentException e) {
    if ("Missing data directory".equals(e.getMessage())) {
        usage();  // print help and exit nonzero
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: Invoking a bsim_ctl subcommand that expects a data directory argument but providing too few args, e.g. `bsim_ctl start` with the directory argument omitted.

Common situations: Missing trailing positional argument; quoting accident that swallowed the path; copy-paste from docs that used a placeholder never replaced; argument reordering.

Related errors


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