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.
This commit is contained in:
Daan van Etten
2025-10-18 00:16:08 +02:00
committed by GitHub
parent 4ce33efa81
commit 6ba77e57e3

View File

@@ -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 {