gastownhall/beads · error

failed to set beads.role config: %w

Error message

failed to set beads.role config: %w

What it means

This error wraps any failure from setBeadsRole during bd init's contributor-mode prompt. promptContributorMode decides whether the user is a maintainer or contributor, then persists 'maintainer' or 'contributor' into the beads.role config. If writing that config value fails (e.g. the config file cannot be written or the underlying config store errors), the error is wrapped with %w and returned, aborting init.

Source

Thrown at cmd/bd/init.go:2993

	// Prompt for role
	fmt.Print("Contributing to someone else's repo? [y/N]: ")

	response, err := readLineWithContext(ctx, reader, os.Stdin)
	if err != nil {
		return false, fmt.Errorf("failed to read input: %w", err)
	}
	response = strings.TrimSpace(strings.ToLower(response))

	isContributor = response == "y" || response == "yes"

	// Set the role in git config
	role := "maintainer"
	if isContributor {
		role = "contributor"
	}

	if err := setBeadsRole(role); err != nil {
		return isContributor, fmt.Errorf("failed to set beads.role config: %w", err)
	}

	return isContributor, nil
}

// promptAutoExport asks the user whether to enable optional auto-export.
// Returns true to enable it, false to leave it disabled.
func promptAutoExport() (bool, error) {
	fmt.Printf("\n%s Auto-export can keep .beads/issues.jsonl up to date after write commands.\n", ui.RenderAccent("▶"))
	fmt.Println("  This optional JSONL export is useful for viewers (bv), interchange, and issue-level migration.")
	fmt.Println("  Dolt remotes/backups handle cross-machine sync and backup.")
	fmt.Print("\nEnable auto-export? [y/N]: ")

	reader := bufio.NewReader(os.Stdin)
	response, err := readLineWithContext(getRootContext(), reader, os.Stdin)
	if err != nil {
		if isCanceled(err) {
			return true, err

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check write permissions on the beads config file/directory and fix with chmod/chown
  2. Run bd init in a directory/user context that can write the config (avoid read-only HOME)
  3. Inspect the beads config file for corruption; repair or delete it so init can recreate it
  4. Re-run bd init; if it persists, run with the config path's error output to identify the underlying wrapped error

Example fix

// before: init fails under read-only HOME
$ bd init
// after: point HOME at a writable location or fix permissions
$ export HOME=/home/writable && bd init
# or
$ chmod u+w ~/.config/beads/
Defensive patterns

Strategy: validation

Validate before calling

if [ ! -w "$HOME/.config/beads" ]; then echo "beads config dir not writable"; exit 1; fi

Try / catch

if _, err := promptContributorMode(); err != nil { var wrapped error; if errors.As(err, &wrapped) { log.Fatalf("init aborted: %v", err) } }

Prevention

When it happens

Trigger: Running bd init, answering the contributor-mode prompt, and setBeadsRole failing because the config file is unwritable, corrupted, or its parent directory is missing.

Common situations: Read-only home directory or BEADS config dir (permissions, sandboxed CI, read-only mounts); disk full; a corrupted beads config file; running init as a different user without write access to the existing config.

Related errors


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