gastownhall/beads · error

failed to set routing.mode: %w

Error message

failed to set routing.mode: %w

What it means

Wraps an error from store.SetConfig when writing 'routing.mode' = 'auto' in autoConfigureForkContributor (the non-interactive fork path; distinct from the wizard's 'failed to set routing mode' message). It means the beads config store for the current repo failed to persist the routing key, aborting fork auto-configuration.

Source

Thrown at cmd/bd/init_contributor.go:336

		gitInit.Dir = planningPath
		if err := gitInit.Run(); err != nil {
			return fmt.Errorf("failed to init git in planning repo: %w", err)
		}
		planningBeadsDir := filepath.Join(planningPath, ".beads")
		if err := os.MkdirAll(planningBeadsDir, 0750); err != nil {
			return fmt.Errorf("failed to create .beads in planning repo: %w", err)
		}
		// Initialize the planning Dolt schema so commands like bd migrate-personal
		// can open the store immediately without hitting an uninitialized DB.
		// Non-fatal: no-CGO and server-mode builds skip this silently; the schema
		// initializes on first use once a Dolt server is running for that path.
		if planningStore, storeErr := newDoltStoreFromConfig(ctx, planningBeadsDir); storeErr == nil {
			_ = planningStore.Close()
		}
	}

	if err := store.SetConfig(ctx, "routing.mode", "auto"); err != nil {
		return fmt.Errorf("failed to set routing.mode: %w", err)
	}
	if err := store.SetConfig(ctx, "routing.contributor", planningPath); err != nil {
		return fmt.Errorf("failed to set routing.contributor: %w", err)
	}
	if err := store.SetConfig(ctx, "sync.remote", "upstream"); err != nil {
		return fmt.Errorf("failed to set sync.remote: %w", err)
	}

	_ = exec.Command("git", "config", "beads.role", "contributor").Run()

	if configPath, err := config.FindConfigYAMLPath(); err == nil {
		if addErr := config.AddRepo(configPath, planningPath); addErr != nil && !strings.Contains(addErr.Error(), "already exists") {
			// Non-fatal: hydration config failure doesn't block routing setup
		}
	}

	if !quiet {
		fmt.Printf("\n%s Fork detected — configuring contributor routing\n", ui.RenderAccent("▶"))

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause and fix the underlying store issue
  2. Run bd init in the fork repo to ensure the .beads store exists, or bd doctor to diagnose it
  3. Ensure the Dolt server is running/reachable for server-mode builds
  4. Retry the fork setup after resolving storage issues (the function is idempotent up to the planning repo check)
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the repo's beads store exists and is writable before fork auto-config
if _, err := os.Stat(filepath.Join(".beads")); err != nil {
	return fmt.Errorf("run bd init in this fork first: %w", err)
}

Try / catch

if err := autoConfigureForkContributor(ctx, store, ...); err != nil {
	var cause error = err
	for errors.Unwrap(cause) != nil { cause = errors.Unwrap(cause) }
	fmt.Fprintf(os.Stderr, "fork setup failed: %v (cause: %v); run bd doctor\n", err, cause)
	return err
}

Prevention

When it happens

Trigger: store.SetConfig(ctx, "routing.mode", "auto") returns an error in autoConfigureForkContributor — the current repo's .beads Dolt store is missing, locked, corrupt, or its server is unreachable. Note the following SetConfig calls for routing.contributor and sync.remote can fail identically.

Common situations: bd run in a fork checkout where bd init was never completed; .beads database locked by another bd process; no Dolt server in server-mode builds; permission/disk problems.

Related errors


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