Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: setup falsely reporting success when native PostgreSQL unavailable

Adam Eivyc8307b3c3c1c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index f29d1e0614..42c83dc4b5 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -10,6 +10,7 @@
- Pipeline artifacts (e.g., REVIEW.md) not cleaned up after final stage — automated cleanup now deletes `fileNotExists` precondition files when pipeline completes
- Self-update failing with "exit code null" at npm-install step — PM2 watch restarted the server during `git checkout` (which changes `server/` files), breaking the stdout pipe to the update script. SIGPIPE killed the script before `|| true` could handle it, leaving the update incomplete. Added `trap '' PIPE` to ignore SIGPIPE so the script runs to completion.
- Improved update error messages to show signal name (e.g., "killed by SIGPIPE") instead of opaque "exit code null"
+- Setup falsely reporting "Setup Complete!" when native PostgreSQL is selected but not installed — now auto-runs `db.sh setup-native` to install and configure PostgreSQL via Homebrew, and exits with error if setup fails instead of silently continuing
### Added
diff --git a/scripts/setup-db.js b/scripts/setup-db.js
index 80ded5d400..45ce2796b5 100644
--- a/scripts/setup-db.js
+++ b/scripts/setup-db.js
@@ -165,6 +165,33 @@ function promptStorageChoice(message, hint) {
});
}
+// Attempt full native PostgreSQL setup via db.sh setup-native
+function setupNativePostgres() {
+ const dbScript = join(rootDir, 'scripts', 'db.sh');
+ try {
+ console.log('🍺 Running native PostgreSQL setup...');
+ execFileSync('bash', [dbScript, 'setup-native'], { stdio: 'inherit', cwd: rootDir });
+ if (isNativeReady()) {
+ console.log('✅ System PostgreSQL ready on port 5432');
+ return true;
+ }
+ } catch (err) {
+ console.error(`⚠️ Native setup error: ${err.message}`);
+ }
+ return false;
+}
+
+// Exit with error when native PostgreSQL setup fails
+function exitNativeSetupFailed() {
+ if (process.platform === 'darwin') {
+ console.error('❌ Native PostgreSQL setup failed — try manually: brew install postgresql@17 && brew services start postgresql@17');
+ } else {
+ console.error('❌ Native PostgreSQL setup failed — install and start PostgreSQL');
+ }
+ console.log(' Then re-run: npm run setup');
+ process.exit(1);
+}
+
async function handleDockerUnavailable(message, issue) {
const hint = getDockerHints(issue);
const choice = await promptStorageChoice(message, hint);
@@ -174,13 +201,13 @@ async function handleDockerUnavailable(message, issue) {
setPgMode('native');
if (isNativeReady()) {
console.log('✅ System PostgreSQL ready on port 5432');
- } else if (process.platform === 'darwin') {
- console.log('⚠️ Native PostgreSQL not detected — try: brew install postgresql@17 && brew services start postgresql@17');
- console.log(' Then re-run setup');
- } else {
- console.log('⚠️ Native PostgreSQL not detected — install and start PostgreSQL, then re-run setup');
+ process.exit(0);
}
- process.exit(0);
+ // Attempt automatic setup via db.sh setup-native (installs + configures)
+ if (setupNativePostgres()) {
+ process.exit(0);
+ }
+ exitNativeSetupFailed();
}
if (choice === 'file') {
@@ -212,21 +239,12 @@ if (mode === 'native') {
process.exit(0);
}
- // Try to start via Homebrew
- if (process.platform === 'darwin') {
- try {
- console.log('🍺 Starting PostgreSQL via Homebrew...');
- execFileSync('brew', ['services', 'start', 'postgresql@17'], { stdio: 'pipe' });
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2000);
- if (isNativeReady()) {
- console.log('✅ System PostgreSQL ready on port 5432');
- process.exit(0);
- }
- } catch { /* fall through */ }
+ // Attempt automatic setup via db.sh (installs + starts + configures)
+ if (setupNativePostgres()) {
+ process.exit(0);
}
- console.warn('⚠️ Native PostgreSQL not running — run: scripts/db.sh setup-native');
- process.exit(0);
+ exitNativeSetupFailed();
}
// Docker mode
diff --git a/setup.sh b/setup.sh
index 97b1045b84..98425d03f9 100755
--- a/setup.sh
+++ b/setup.sh
@@ -24,7 +24,16 @@ npm install
echo ""
echo "Setting up data directory..."
-npm run setup
+if ! npm run setup; then
+ echo ""
+ echo "==================================="
+ echo " Setup incomplete"
+ echo "==================================="
+ echo ""
+ echo "Fix the issue above, then re-run: ./setup.sh"
+ echo ""
+ exit 1
+fi
echo ""