plandex-ai/plandex · error

error selecting account: %v

Error message

error selecting account: %v

What it means

SelectOrSignInOrCreate in app/cli/auth/account.go wraps failures from term.SelectFromList as 'error selecting account: %v'. This happens when existing accounts are present and the CLI shows an interactive list; an error from the terminal selection UI (not the later 'account not found' check) is wrapped here.

Source

Thrown at app/cli/auth/account.go:42

			return fmt.Errorf("error signing in to new account: %v", err)
		}

		return nil
	}

	var options []string
	for _, account := range accounts {
		options = append(options, fmt.Sprintf("<%s> %s", account.UserName, account.Email))
	}

	options = append(options, AddAccountOption)

	// either select from existing accounts or sign in/create account

	selectedOpt, err := term.SelectFromList("Select an account:", options)

	if err != nil {
		return fmt.Errorf("error selecting account: %v", err)
	}

	if selectedOpt == AddAccountOption {
		err := promptSignInNewAccount()
		if err != nil {
			return fmt.Errorf("error prompting for sign in to new account: %v", err)
		}
		return nil
	}

	var selected *shared.ClientAccount
	for i, opt := range options {
		if selectedOpt == opt {
			selected = accounts[i]
			break
		}
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Run the command in an interactive terminal with a working TTY and standard TERM setting.
  2. Avoid piping/redirecting stdin when invoking auth commands.
  3. If selection keeps aborting, check whether the terminal emulator intercepts the cancel key and retry.
  4. As a workaround, remove stale accounts from the store so the CLI goes straight to the sign-in prompt, or manage accounts via available non-interactive flags.

Example fix

// before
plandex sign-in < /dev/null   # non-interactive stdin -> error selecting account
// after
plandex sign-in               # run in a real interactive terminal
Defensive patterns

Strategy: validation

Validate before calling

// Confirm an interactive TTY exists before presenting the account list
func canInteract() bool {
    fi, _ := os.Stdin.Stat()
    return fi.Mode()&os.ModeCharDevice != 0
}
if !canInteract() {
    return errors.New("account selection requires an interactive terminal")
}

Type guard

func isSelectAccountError(err error) bool {
    return err != nil && strings.HasPrefix(err.Error(), "error selecting account:")
}

Try / catch

if err := auth.SelectOrSignInOrCreate(); err != nil {
    if isSelectAccountError(err) {
        fmt.Fprintln(os.Stderr, "account selection failed or was cancelled; rerun in an interactive terminal")
        os.Exit(1)
    }
    log.Fatal(err)
}

Prevention

When it happens

Trigger: term.SelectFromList("Select an account:", options) returns an error while the user picks among existing accounts — typically a terminal I/O problem (non-TTY stdin, interrupted read) or the user aborting/cancelling the selection.

Common situations: Running the CLI in CI, scripts, or with redirected stdin where no interactive list can render; pressing Ctrl+C/Esc during selection; terminal library failing on an unusual TERM setting or tiny terminal window.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/b703abbc20d04023. Report an issue: GitHub.