{"record":{"id":"38658a114c6972de","repo":"NationalSecurityAgency/ghidra","slug":"postgresql-pg-ctl-command-not-found","errorCode":null,"errorMessage":"PostgreSQL pg_ctl command not found: {}","messagePattern":"PostgreSQL pg_ctl command not found: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":784,"sourceCode":"\t\t}\n\t\telse {\n\t\t\tloadLibraryVar = \"LD_LIBRARY_PATH\";\n\t\t}\n\t\tFile postgresLibrary = new File(postgresRoot, \"lib\");\n\t\tloadLibraryValue = postgresLibrary.getAbsolutePath();\n\t}\n\n\t/**\n\t * Locate the \"pg_ctl\" executable within the PostgreSQL installation. Unpack the installation\n\t * if it is not already.\n\t * @throws IOException if postgres folder cannot be determined\n\t */\n\tprivate void discoverPostgresInstall() throws IOException {\n\t\ttry {\n\t\t\tpostgresRoot = Application.getOSFile(POSTGRES);\t// find PostgreSQL build for os\n\t\t\tpostgresControl = new File(postgresRoot, \"bin/pg_ctl\");\n\t\t\tif (!postgresControl.isFile()) {\n\t\t\t\tthrow new IOException(\"PostgreSQL pg_ctl command not found: \" + postgresControl);\n\t\t\t}\n\t\t\tsetupPostgresSharedLibrary();\n\t\t}\n\t\tcatch (OSFileNotFoundException e) {\n\t\t\tthrow new IOException(\"PostgreSQL not found and must be built (see \" +\n\t\t\t\tPOSTGRES_BUILD_SCRIPT + \", view script for details)\");\n\t\t}\n\t}\n\n\t/**\n\t * Recover the parameter settings from a previously initialized server\n\t * @param configFile is main configuration file: port, adminPassword, hostAuthentication\n\t * @param hbaFile is the connection file\n\t * @throws IOException if the server port is invalid\n\t */\n\tprivate void recoverConfigurationParameters(File configFile, File hbaFile) throws IOException {\n\t\tServerConfig serverConfig = new ServerConfig();\n\t\tserverConfig.addKey(\"port\", \"\");","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L766-L802","documentation":"Thrown by discoverPostgresInstall when Application.getOSFile(POSTGRES) located a postgres root directory but bin/pg_ctl is not a regular file there. The install bundle is present but incomplete or corrupt, so the control binary cannot be invoked.","triggerScenarios":"The OS-specific postgres bundle exists under the application layout, yet `new File(postgresRoot, \"bin/pg_ctl\").isFile()` is false, firing at line 784.","commonSituations":"Partial/corrupted extraction of the postgres bundle, wrong platform bundle for the host OS/arch, or files removed after extraction.","solutions":["Re-extract or rebuild the postgres bundle so bin/pg_ctl is present.","Verify bin/pg_ctl exists and is executable for the current OS/arch.","Confirm the bundle matches the host platform (Application.getOSFile selects per-OS)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify pg_ctl exists in the postgres bundle before invoking the tool.\nFile pgCtl = new File(postgresRoot, \"bin/pg_ctl\");\nif (!pgCtl.isFile()) {\n    System.err.println(\"bin/pg_ctl missing under \" + postgresRoot + \"; re-extract the bundle.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    launchable.discoverPostgresInstall();\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"PostgreSQL pg_ctl command not found:\")) {\n        System.err.println(\"Postgres bundle incomplete; rebuild/re-extract it.\");\n    }\n    throw e;\n}","preventionTips":["After extracting the postgres bundle, verify bin/pg_ctl is present and executable.","Use the OS/arch-matching bundle (Application.getOSFile selects per platform).","Re-extract if files appear missing or corrupted."],"tags":["postgresql","environment","setup","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}