gastownhall/beads · error

%v

Error message

%v

What it means

Generic wrapper: during bd init, an underlying workspace-check/initialization error (from checking whether the workspace already exists) is returned verbatim (%v) with no additional context. The real cause is whatever the inner existing-workspace probe returned — e.g. corrupted .beads config or an unreadable state.

Source

Thrown at cmd/bd/init.go:795

					// the request and reuse a different database. --database is
					// the authoritative selector, so it is checked even when
					// --prefix is also set.
					existing := existingWorkspaceDBName()
					if cmd.Flags().Changed("database") {
						if initIfMissingDatabaseMismatch(existing, database) {
							return fmt.Errorf("workspace already initialized as database %q, but --database %q was requested.\nRemove --database (or pass a matching value) to reuse the existing workspace", existing, database)
						}
					} else if cmd.Flags().Changed("prefix") {
						if initIfMissingPrefixMismatch(existing, prefix) {
							return fmt.Errorf("workspace already initialized as database %q, but --prefix %q was requested.\nRemove --prefix (or pass a matching value) to reuse the existing workspace", existing, prefix)
						}
					}
					if !quiet {
						fmt.Fprintln(os.Stderr, "Skipping init: workspace already initialized.")
					}
					return nil
				}
				return fmt.Errorf("%v", err)
			}
		}

		// Check BEADS_DB environment variable if --db flag not set
		// (PersistentPreRun doesn't run for init command)
		if dbPath == "" {
			if envDB := os.Getenv("BEADS_DB"); envDB != "" {
				dbPath = envDB
			}
		}

		// Determine prefix with precedence: flag > config > auto-detect from git > auto-detect from directory name
		if prefix == "" {
			// Try to get from config file
			prefix = config.GetString("issue-prefix")
		}

		// auto-detect prefix from directory name

View on GitHub (pinned to 71377f2769)

Solutions

  1. Inspect .beads/config.yaml for corruption and fix or remove it
  2. Re-run with verbose/debug output to surface the underlying error
  3. If unrecoverable, back up and remove .beads, then run bd init again
Defensive patterns

Strategy: try-catch

Validate before calling

bd doctor || echo "resolve workspace issues before re-init"

Try / catch

if err := bdInit(); err != nil { return fmt.Errorf("bd init failed: %w — check .beads/config.yaml integrity", err) }

Prevention

When it happens

Trigger: `bd init` in a directory where the existing-workspace detection call returns an error other than 'already initialized' (e.g. malformed .beads/config.yaml, permission problem reading workspace state).

Common situations: Partially deleted .beads directories; config files corrupted by merge conflicts; read-only mounts.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/183bd6b95e997a7a. Report an issue: GitHub.