{"record":{"id":"1ac11aab16b9fc17","repo":"NationalSecurityAgency/ghidra","slug":"postgresql-not-found-and-must-be-built-see-vi","errorCode":null,"errorMessage":"PostgreSQL not found and must be built (see {}, view script for details)","messagePattern":"PostgreSQL not found and must be built \\(see (.+?), view script for details\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":789,"sourceCode":"\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\", \"\");\n\t\tserverConfig.scanConfig(configFile);\n\t\tString value = serverConfig.getValue(\"port\");\n\t\tint scannedPort = 5432;\n\t\tif (value.length() != 0) {\n\t\t\tscannedPort = Integer.parseInt(value);","sourceCodeStart":771,"sourceCodeEnd":807,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L771-L807","documentation":"Thrown when Application.getOSFile(POSTGRES) raises OSFileNotFoundException, meaning no OS-specific postgres bundle is installed at all. Unlike [677], the directory was never found, so the tool points the user to the build script.","triggerScenarios":"First-time setup on a machine where the postgres support bundle has not been built/downloaded; getOSFile cannot resolve any POSTGRES file for the OS (line 789).","commonSituations":"Fresh checkout/install without running the postgres build step, or the bundle not yet distributed for this platform.","solutions":["Run the referenced POSTGRES_BUILD_SCRIPT and follow its instructions to build postgres.","Re-run the BSim command only after the build completes successfully.","Confirm the build produced the OS-specific postgres layout Application.getOSFile expects."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check whether the OS postgres bundle is resolvable before launching.\ntry {\n    File root = Application.getOSFile(POSTGRES);\n    if (root == null || !root.exists()) {\n        System.err.println(\"Postgres bundle not installed. Run \" + POSTGRES_BUILD_SCRIPT);\n        return;\n    }\n} catch (OSFileNotFoundException e) {\n    System.err.println(\"Postgres not built yet. Run \" + POSTGRES_BUILD_SCRIPT);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    launchable.discoverPostgresInstall();\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"PostgreSQL not found and must be built\")) {\n        System.err.println(\"Build postgres first via the referenced script, then retry.\");\n    }\n    throw e;\n}","preventionTips":["Run the postgres build script during initial setup before any BSim server command.","Confirm the build produced the OS-specific layout the tool expects.","Surface a clear 'run the build script' message when the bundle is absent."],"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"}