gastownhall/beads · error
measure active database directory %q: %w
Error message
measure active database directory %q: %w
What it means
EmbeddedDoltStore failed to compute the on-disk size of the active embedded Dolt database directory (s.CLIDir()). The wrapped error comes from storage.MeasureDirectorySize, so the underlying cause (missing directory, permission denial, context cancellation, filesystem error) is preserved. This store method implements the size/diagnostics surface of the storage interface and cannot report a size when the directory cannot be read or measured.
Source
Thrown at internal/storage/embeddeddolt/store.go:848
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,
// Commit itself tolerates Dolt's "nothing to commit" response (matching the
// server store) and returns nil for it, so an error-based check here would
// report every clean-store call as "committed", and a HEAD-before/HEAD-after
// comparison would cost two extra engine opens on every call (this runs onView on GitHub (pinned to 71377f2769)
Solutions
- Inspect the wrapped cause (%w) to determine whether it is a filesystem permission, missing-directory, or context error and fix that root cause first.
- Verify the active database directory exists: run `ls` on the path printed in the error and confirm it contains the embedded Dolt database.
- Fix permissions so the process user can read/traverse the directory (e.g. chown/chmod the .beads database directory).
- If the directory is gone or corrupted, restore it (bd recovery/export flow) or re-initialize the embedded store before measuring again.
- Avoid cancelling the command; on very large databases give the size operation more time or a longer context deadline.
Example fix
// before: measuring without ensuring the dir is usable
size, err := store.MeasureSize(ctx)
// after: pre-check directory access before calling
dir := store.ActiveDir()
if _, statErr := os.Stat(dir); statErr != nil {
return fmt.Errorf("active db dir %q unavailable: %w", dir, statErr)
}
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
size, err := store.MeasureSize(ctx) Defensive patterns
Strategy: validation
Validate before calling
dir := store.ActiveDir() // or however CLIDir is exposed
if dir == "" {
return errors.New("embedded store has no active database directory")
}
if fi, err := os.Stat(dir); err != nil || !fi.IsDir() {
return fmt.Errorf("active db dir %q unavailable: %w", dir, err)
}
if err := ctx.Err(); err != nil {
return err
} Try / catch
var sizeErr *fs.PathError
if err := measure(ctx); err != nil {
if errors.As(err, &sizeErr) {
// permission / missing dir on the db directory
}
if errors.Is(err, context.DeadlineExceeded) {
// retry with longer budget
}
return err
} Prevention
- Never move or delete the .beads embedded database directory while bd commands may run.
- Run bd as a user with read access to the database directory (watch sudo/service-account setups).
- Set generous context timeouts for size/diagnostic operations on large databases.
- Verify store initialization succeeded before calling size/diagnostic methods.
When it happens
Trigger: Calling the store's size-measuring storage method (which routes to MeasureDirectorySize) when CLIDir() returns an empty path (that case has its own error), when the active database directory does not exist or was moved, when the process lacks read/search permission on the directory, or when the passed context is cancelled/timed out mid-walk.
Common situations: Running bd against an embedded Dolt database whose .beads data directory was deleted or relocated; running as a different user (e.g. via sudo/service account) without read access to the database dir; long-running size/diagnostic commands cancelled by context timeout on very large databases; WAL/working-tree inconsistencies leaving the CLIDir unset.
Related errors
- persisting sanitized database name to metadata.json: %w
- no store is open for this workspace
- not found
- multiple .doltcfg directories detected
- dolt path is not executable
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/794941db2d693dc8.
Report an issue: GitHub.