gastownhall/beads · error
%s; %s
Error message
%s; %s
What it means
backupDir's fallback path uses the beads workspace directory (.beads/backup). When beads.FindBeadsDir() returns empty, it fails with '%s; %s' combining the shared 'no active beads workspace found' message and diagHint() ('run bd where to inspect the resolved workspace, or bd init to create a new database'). This is the terminal error when neither the configured git-repo nor a workspace is available.
Source
Thrown at cmd/bd/backup_export.go:47
gitRepo := config.GetString("backup.git-repo")
if gitRepo != "" {
if strings.HasPrefix(gitRepo, "~/") {
home, _ := os.UserHomeDir()
gitRepo = filepath.Join(home, gitRepo[2:])
}
if _, err := os.Stat(filepath.Join(gitRepo, ".git")); err != nil {
fmt.Fprintf(os.Stderr, "Warning: backup.git-repo %s is not a git repo, falling back to .beads/backup\n", gitRepo)
} else {
dir := filepath.Join(gitRepo, "backup")
if err := os.MkdirAll(dir, 0700); err != nil {
return "", fmt.Errorf("failed to create backup dir in git-repo: %w", err)
}
return dir, nil
}
}
beadsDir := beads.FindBeadsDir()
if beadsDir == "" {
return "", fmt.Errorf("%s; %s", activeWorkspaceNotFoundError(), diagHint())
}
dir := filepath.Join(beadsDir, "backup")
if err := os.MkdirAll(dir, 0700); err != nil {
return "", fmt.Errorf("failed to create backup directory: %w", err)
}
return dir, nil
}
// loadBackupState reads the backup state file, returning a zero state if missing.
func loadBackupState(dir string) (*backupState, error) {
path := filepath.Join(dir, "backup_state.json")
data, err := os.ReadFile(path) //nolint:gosec // path is constructed internally
if os.IsNotExist(err) {
return &backupState{}, nil
}
if err != nil {
return nil, fmt.Errorf("failed to read backup state: %w", err)
}View on GitHub (pinned to 71377f2769)
Solutions
- Run 'bd init' in the repo to create the .beads workspace
- Run 'bd where' (per the hint) to see how bd resolved the workspace and fix cwd/BEADS_DIR
- Set a valid, writable backup.git-repo so the primary path is used instead of the fallback
- cd into the workspace root before running backup commands
Example fix
// before cd /tmp && bd backup export // error: no active beads workspace found; run 'bd where' ... // after cd /path/to/bd-repo && bd backup export # or: bd init
Defensive patterns
Strategy: validation
Validate before calling
if beads.FindBeadsDir() == "" {
return errors.Errorf("no active beads workspace found; %s", diagHint())
}
// then safe to call backupDir() Try / catch
dir, err := backupDir()
if err != nil {
if strings.Contains(err.Error(), "no active beads workspace found") {
return fmt.Errorf("initialize first: bd init (hint included in error)")
}
return err
} Prevention
- Run bd init before any backup/export automation
- Include a 'bd where' precondition check in scripts and CI
- Keep .beads committed/checked out so clones are valid workspaces
When it happens
Trigger: Running backup export or auto-backup outside any beads workspace, or with backup.git-repo unset/invalid so the code falls through to FindBeadsDir which returns empty (no .beads found up the tree, BEADS_DIR unset/invalid).
Common situations: Running `bd backup export` in a plain git repo without bd init, deleted .beads directory, scripts run from $HOME or /tmp, misconfigured backup.git-repo triggering the fallback into a workspace-less cwd.
Related errors
- %s
- no backup destination configured
- failed to remove backup: %w
- failed to create backup dir in git-repo: %w
- failed to create backup directory: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/fba70e27eb108e3d.
Report an issue: GitHub.