plandex-ai/plandex · error

error selecting or signing in to account: %v

Error message

error selecting or signing in to account: %v

What it means

promptInitialAuth is a pure wrapper: it runs the first-time account setup (SelectOrSignInOrCreate) and re-wraps any failure as 'error selecting or signing in to account: %v'. It fires when a user with no stored accounts runs a command that triggers MustResolveAuth. The real cause is always the nested error from the account selection/sign-in flow.

Source

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

		Pin:          code,
		IsSignInCode: true,
	}, host)
	term.StopSpinner()

	if apiErr != nil {
		return fmt.Errorf("error signing in: %v", apiErr.Msg)
	}

	return handleSignInResponse(res, host)
}

func promptInitialAuth() error {
	fmt.Println("👋 Hey there!\nIt looks like this is your first time using Plandex on this computer.")

	err := SelectOrSignInOrCreate()

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

	return nil
}

const (
	// SignInCloudOption = "Plandex Cloud"
	SignInLocalOption = "Local mode host"
	SignInOtherOption = "Another host"
)

func promptSignInNewAccount() error {
	selected, err := term.SelectFromList("Use local mode or another host?", []string{SignInLocalOption, SignInOtherOption})

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

View on GitHub (pinned to e2d772072e)

Solutions

  1. Inspect the nested error after the colon — it identifies the failing sub-step (load, select, prompt, or API call).
  2. Run the command in an interactive terminal so term.SelectFromList and user inputs can succeed.
  3. If the accounts file is corrupt or empty unexpectedly, remove/reset it and re-run to start first-time setup cleanly.
  4. Pre-authenticate non-interactively (e.g. complete sign-in once manually) before running in CI.
Defensive patterns

Strategy: validation

Validate before calling

// check for an existing authenticated session before triggering first-time setup
if auth.Current == nil && !term.IsInteractive() {
    return fmt.Errorf("no Plandex account configured; run 'plandex auth' in an interactive terminal first")
}

Try / catch

if err := promptInitialAuth(); err != nil {
    var cause = errors.Unwrap(err) // inspect nested SelectOrSignInOrCreate failure
    log.Printf("first-time auth failed: %v (cause: %v)", err, cause)
    return err
}

Prevention

When it happens

Trigger: MustResolveAuth detects no existing accounts and calls promptInitialAuth; SelectOrSignInOrCreate fails (account list load failure, list selection failure, or any error from promptSignInNewAccount such as API or prompt errors).

Common situations: First run of the CLI on a new machine; after deleting the accounts config file; non-interactive environments (CI, scripts) where the interactive prompts cannot read input; corrupted accounts file making loadAccounts fail.

Related errors


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