From 6ba77e57e3e04c61a6b67529fae5ad85be4ca647 Mon Sep 17 00:00:00 2001 From: Daan van Etten Date: Sat, 18 Oct 2025 00:16:08 +0200 Subject: [PATCH] Fix daemon database discovery to match other commands (#70) The daemon command was failing to find the database while other commands like 'bd list' could find it. This was because ensureBeadsDir() was not using the same database discovery logic as other commands. This fix updates ensureBeadsDir() to use beads.FindDatabasePath() API, the same discovery mechanism used by all other commands, ensuring consistent behavior across the CLI. --- cmd/bd/daemon.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/bd/daemon.go b/cmd/bd/daemon.go index 07feb291..025a5e35 100644 --- a/cmd/bd/daemon.go +++ b/cmd/bd/daemon.go @@ -115,8 +115,14 @@ func ensureBeadsDir() (string, error) { if dbPath != "" { beadsDir = filepath.Dir(dbPath) } else { - // No database path - error out instead of falling back to ~/.beads - return "", fmt.Errorf("no database path configured (run 'bd init' or set BEADS_DB)") + // Use public API to find database (same logic as other commands) + if foundDB := beads.FindDatabasePath(); foundDB != "" { + dbPath = foundDB // Store it for later use + beadsDir = filepath.Dir(foundDB) + } else { + // No database found - error out instead of falling back to ~/.beads + return "", fmt.Errorf("no database path configured (run 'bd init' or set BEADS_DB)") + } } if err := os.MkdirAll(beadsDir, 0700); err != nil {