charmbracelet/gum · error

nothing selected

Error message

nothing selected

What it means

gum choose returns this error when the bubbletea program exits without a submission — the user quit or pressed esc/ctrl-c instead of confirming a selection. The model's `submitted` flag was false at the end of Run.

Source

Thrown at choose/command.go:158

		help:              help.New(),
		keymap:            km,
	}

	ctx, cancel := timeout.Context(o.Timeout)
	defer cancel()

	// Disable Keybindings since we will control it ourselves.
	tm, err := tea.NewProgram(
		m,
		tea.WithOutput(os.Stderr),
		tea.WithContext(ctx),
	).Run()
	if err != nil {
		return fmt.Errorf("unable to pick selection: %w", err)
	}
	m = tm.(model)
	if !m.submitted {
		return errors.New("nothing selected")
	}
	if o.Ordered && o.Limit > 1 {
		sort.Slice(m.items, func(i, j int) bool {
			return m.items[i].order < m.items[j].order
		})
	}

	var out []string
	for _, item := range m.items {
		if item.selected {
			out = append(out, options[item.text])
		}
	}
	tty.Println(strings.Join(out, o.OutputDelimiter))
	return nil
}

View on GitHub (pinned to 4d089f9550)

Solutions

  1. Handle the non-zero exit as 'user cancelled' and branch accordingly in your script
  2. Check for available choices so users can actually select something
  3. Consider whether esc/ctrl-c keys are mapped for submission if headless behavior is needed

Example fix

// before
choice=$(gum choose a b c) || exit 1
// after
choice=$(gum choose a b c) || { echo "cancelled"; exit 0; }
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

if ! choice=$(gum choose a b c); then
  echo 'user cancelled selection'
  exit 0
fi
printf '%s\n' "$choice"

Prevention

When it happens

Trigger: tea.Program.Run() completes, tm is cast to model, and m.submitted is false — i.e. the user dismissed the picker without choosing (esc, ctrl-c, or q depending on keymap).

Common situations: Users pressing Esc/Ctrl-C in interactive scripts; CI or non-TTY environments aborting the TUI; timeouts killing the program.

Related errors


AI-assisted analysis of charmbracelet/gum@4d089f9550 (2026-08-31). Data as JSON: /api/errors/c6c374cc3506be61. Report an issue: GitHub.