lima-vm/lima · error

unexpected answer %d

Error message

unexpected answer %d

What it means

chooseNextCreatorState presents an interactive 4-option TUI menu (proceed, edit, choose template, exit) via uiutil.Select. This error is thrown when Select returns an answer index outside 0-3, which should be impossible with a well-behaved TUI. It is a defensive guard against out-of-range UI selection values.

Source

Thrown at cmd/limactl/start.go:519

			if tmpl.Name == "" {
				tmpl.Name, err = limatmpl.InstNameFromYAMLPath(yamlPath)
				if err != nil {
					return nil, err
				}
			}
			tmpl, err = limatmpl.Read(ctx, tmpl.Name, yamlPath)
			if err != nil {
				return nil, err
			}
			err = tmpl.Embed(ctx, true, true)
			if err != nil {
				return nil, err
			}
			continue
		case 3: // "Exit"
			return nil, exitSuccessError{Msg: "Choosing to exit"}
		default:
			return tmpl, fmt.Errorf("unexpected answer %d", ans)
		}
	}
}

// createStartActionCommon is shared by createAction and startAction.
func createStartActionCommon(cmd *cobra.Command, _ []string) (exit bool, err error) {
	if listTemplates, err := cmd.Flags().GetBool("list-templates"); err != nil {
		return true, err
	} else if listTemplates {
		templates, err := filterHiddenTemplates()
		if err != nil {
			return true, err
		}
		w := cmd.OutOrStdout()
		for _, f := range templates {
			_, _ = fmt.Fprintln(w, f.Name)
		}
		return true, nil

View on GitHub (pinned to dd909d0973)

Solutions

  1. Retry `limactl start` in a standard interactive terminal (TTY)
  2. Update Lima to the latest version in case of a TUI library bug
  3. Pass the template/YAML directly and use flags to skip the interactive menu (e.g. `limactl start --name X template.yaml`, `--tty=false`)
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure a real TTY and stock limactl before interactive start
test -t 0 || { echo 'interactive start needs a TTY; use: limactl start --name X template.yaml' >&2; exit 1; }

Try / catch

out=$(limactl start --tty=false template://default --name inst 2>&1) || { echo "$out"; }

Prevention

When it happens

Trigger: uiutil.Select returns an integer >3 (or negative) during `limactl start`/`limactl create` when the instance needs creating and the interactive menu is shown; effectively only occurs from a TUI bug, a broken terminal backend, or a forked/modified option list.

Common situations: Running limactl in a non-interactive or misbehaving terminal emulator where the selection library misbehaves; custom builds of Lima with modified menu options but stale switch cases.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/6ae880b49035ceaf. Report an issue: GitHub.