gastownhall/beads · error
embeddeddolt: active database directory is empty
Error message
embeddeddolt: active database directory is empty
What it means
ActiveDatabaseSize reports the on-disk size of the active embedded database by measuring s.CLIDir(); this error is returned when CLIDir() yields an empty string, meaning the store has no resolvable active database directory (misconfigured or not yet initialized store). Note the store's closed flag is checked first (errClosed), so this specifically indicates an open store whose CLI directory is empty. Measurement never even starts in this case.
Source
Thrown at internal/storage/embeddeddolt/store.go:844
// CLIDir returns the directory for dolt CLI operations (push/pull/remote).
// This is the actual database directory within the data dir.
func (s *EmbeddedDoltStore) CLIDir() string {
if s.dataDir == "" {
return ""
}
return filepath.Join(s.dataDir, s.database)
}
// ActiveDatabaseSize returns the approximate size of this store's active
// database directory. Sibling databases under the embedded data root are not
// part of the result.
func (s *EmbeddedDoltStore) ActiveDatabaseSize(ctx context.Context) (int64, error) {
if s.closed.Load() {
return 0, errClosed
}
activeDir := s.CLIDir()
if activeDir == "" {
return 0, fmt.Errorf("embeddeddolt: active database directory is empty")
}
size, err := storage.MeasureDirectorySize(ctx, activeDir)
if err != nil {
return 0, fmt.Errorf("measure active database directory %q: %w", activeDir, err)
}
return size, nil
}
// ---------------------------------------------------------------------------
// storage.VersionControl
// ---------------------------------------------------------------------------
// Branch, Checkout, CurrentBranch, DeleteBranch, ListBranches are
// implemented in version_control.go via versioncontrolops.
// CommitPending commits all working set changes and reports whether a commit
// actually landed. It gets that from commitAll's returned bool rather than
// inspecting Commit's error or reading HEAD before and after: as of GH#3886,View on GitHub (pinned to 71377f2769)
Solutions
- Construct the store through newStore with a valid DataDir rather than direct struct instantiation.
- Verify the configured data directory (.beads metadata / config) points at an existing Dolt database directory.
- Run 'bd doctor' to confirm the store configuration resolves to a real database directory.
- If writing library code, treat an empty CLIDir as uninitialized and initialize before querying size.
Example fix
// before
store := &EmbeddedDoltStore{} // CLIDir() == ""
size, err := store.ActiveDatabaseSize(ctx)
// after
store, err := newStore(ctx, EmbeddedDoltConfig{DataDir: "/repo/.beads/dolt"})
size, err := store.ActiveDatabaseSize(ctx) Defensive patterns
Strategy: validation
Validate before calling
dir := store.CLIDir()
if dir == "" {
return fmt.Errorf("store not configured with a data directory")
}
if _, err := os.Stat(dir); err != nil {
return fmt.Errorf("database dir %q missing: %w", dir, err)
} Try / catch
size, err := store.ActiveDatabaseSize(ctx)
if err != nil && strings.Contains(err.Error(), "active database directory is empty") {
// rebuild store via newStore with a valid DataDir, then retry
return fmt.Errorf("store uninitialized: %w", err)
} Prevention
- Always construct stores via newStore with a non-empty DataDir
- Never instantiate EmbeddedDoltStore directly in application code
- Verify .beads metadata resolves to a real database directory before size reporting
- Guard monitoring code to skip stores without a configured directory
When it happens
Trigger: Calling ActiveDatabaseSize on an EmbeddedDoltStore constructed without a data directory / CLI dir configuration such that CLIDir() returns "" — e.g. a zero-value or partially configured store, or a store whose dataDir resolution failed silently; typically only via direct library use or unusual configuration rather than normal bd operation.
Common situations: Programmatic use constructing EmbeddedDoltStore without setting DataDir; tests or tooling instantiating the store directly instead of via newStore; monitoring scripts calling size reporting on a misconfigured store.
Related errors
- invalid database name: %q; hyphens are not allowed in embedd
- embeddeddolt: invalid database name: %q; hyphens are not all
- embeddeddolt: setting branch: %w
- multiple .doltcfg directories detected
- dolt directory is required
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/06aeb4da5b61d64f.
Report an issue: GitHub.