{"record":{"id":"1fa05676e903640f","repo":"NationalSecurityAgency/ghidra","slug":"data-directory-not-initialized-run-bsim-ctl-star","errorCode":null,"errorMessage":"Data directory not initialized: run \"bsim_ctl start\" first","messagePattern":"Data directory not initialized: run \"bsim_ctl start\" first","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":1273,"sourceCode":"\n\t/**\n\t * The data directory for a server (which must not be running) is reconfigured\n\t * with new local and remote authentication options, and the port may be reconfigured as well.\n\t * Database records are unaltered.\n\t * The user submits \"auth=..\", \"localAuth=..\", and \"port=..\" options on the command line:\n\t * among those submitted, any option that doesn't match the current configuration is changed.\n\t * @throws IOException if the postgres installation cannot be found\n\t * @throws InterruptedException if the postgres installation cannot be found\n\t * @throws SAXException if the {@link #tuneConfig(File, File, File, File, File)} call fails\n\t * @throws GeneralSecurityException if there is no Distinguished Name supplied\n\t */\n\tprivate void changeAuthCommand()\n\t\t\tthrows IOException, InterruptedException, SAXException, GeneralSecurityException {\n\t\tdiscoverPostgresInstall();\n\t\tFile configFile = new File(dataDirectory, POSTGRES_CONFIGFILE);\n\t\tFile hbaFile = new File(dataDirectory, POSTGRES_CONNECTFILE);\n\t\tif (!configFile.exists()) {\n\t\t\tthrow new IOException(\"Data directory not initialized: run \\\"bsim_ctl start\\\" first\");\n\t\t}\n\t\tint requestedLocalAuth = localAuthentication;\n\t\tint requestedHostAuth = hostAuthentication;\n\t\tint requestedPort = port;\n\t\tport = -1;\n\t\trecoverConfigurationParameters(configFile, hbaFile);\n\t\tif (isServerRunning()) {\n\t\t\tthrow new IOException(\"Cannot modify settings on running server\");\n\t\t}\n\t\tif ((!authConfigPresent || (requestedHostAuth == hostAuthentication &&\n\t\t\trequestedLocalAuth == localAuthentication)) &&\n\t\t\t(requestedPort == -1 || requestedPort == port)) {\n\t\t\tSystem.out.println(\"No changes to make\");\n\t\t\treturn;\n\t\t}\n\n\t\tFile serverConfigFile = Application.getModuleDataFile(\"serverconfig.xml\").getFile(false);\n\t\tFile configCopy = new File(dataDirectory, POSTGRES_CONFIGFILE + \".orig\");","sourceCodeStart":1255,"sourceCodeEnd":1291,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L1255-L1291","documentation":"Thrown by BSimControlLaunchable.changeAuthCommand() when the BSim PostgreSQL data directory has not been initialized. The method expects a 'postgresql.conf' file inside the data directory, which is only created when 'bsim_ctl start' runs 'initdb' against that directory. The IOException signals that the configuration files needed to change authentication settings do not exist yet.","triggerScenarios":"Running 'bsim_ctl changeauth <datadir-path>' against a data directory that was never initialized (no postgresql.conf present), or pointing changeauth at a wrong/non-existent directory path.","commonSituations":"Operator runs changeauth before ever starting the server; pointing at a stale or accidentally-deleted data directory; copy-pasting the wrong datadir argument.","solutions":["Run 'bsim_ctl start <datadir-path>' first to initialize the PostgreSQL data directory.","Verify the datadir path is correct and that <datadir>/postgresql.conf exists.","If the directory was never initialized, start fresh with 'bsim_ctl start' to generate it."],"exampleFix":"# before (fails: datadir never initialized)\nbsim_ctl changeauth /opt/bsim/newdir --auth password\n# after (initialize first)\nbsim_ctl start /opt/bsim/newdir --auth password\nbsim_ctl changeauth /opt/bsim/newdir --auth password","handlingStrategy":"try-catch","validationCode":"// Before invoking changeauth, confirm the data directory is initialized:\nFile conf = new File(dataDirectory, \"postgresql.conf\");\nif (!conf.exists()) {\n    throw new IllegalStateException(\"Run 'bsim_ctl start \" + dataDirectory + \"' first\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    bsimControl.run(new String[]{\"changeauth\", dataDir, \"--auth\", \"password\"});\n} catch (IOException e) {\n    if (e.getMessage().contains(\"not initialized\")) {\n        // prompt operator to run 'bsim_ctl start' first\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always run 'bsim_ctl start' to initialize a data directory before changeauth.","Script a directory-existence/initialization check before reconfiguration commands.","Document the required command order in deployment runbooks."],"tags":["bsim","postgres","cli","configuration"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}