plandex-ai/plandex · error
error loading accounts: %v
Error message
error loading accounts: %v
What it means
SelectOrSignInOrCreate in app/cli/auth/account.go wraps any failure from loadAccounts() — reading the locally stored account/auth files — as 'error loading accounts: %v'. It means the CLI could not read or parse the on-disk account store before presenting the account selection UI, so the underlying I/O or deserialization error is preserved in the wrapped message.
Source
Thrown at app/cli/auth/account.go:18
package auth
import (
"fmt"
"plandex-cli/term"
shared "plandex-shared"
"github.com/fatih/color"
)
const AddAccountOption = "Add another account"
func SelectOrSignInOrCreate() error {
accounts, err := loadAccounts()
if err != nil {
return fmt.Errorf("error loading accounts: %v", err)
}
if len(accounts) == 0 {
err := promptSignInNewAccount()
if err != nil {
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)
View on GitHub (pinned to e2d772072e)
Solutions
- Inspect the wrapped cause (%v) in the message to identify the actual I/O or parse failure.
- Check permissions and existence of the CLI's auth/accounts storage directory (typically under your home config dir) and fix ownership with chown/chmod.
- If the file is corrupted, back it up and remove/rename it so the CLI re-creates it, then sign in again.
- Ensure HOME (or XDG config path) is set correctly, especially when running under sudo, cron, or containers.
Example fix
// before sudo plandex sign-in # runs as root, can't read user's accounts file -> error loading accounts // after plandex sign-in # run as the owning user, accounts file readable
Defensive patterns
Strategy: validation
Validate before calling
// Before invoking auth flows, ensure the accounts store is readable
accountsPath := authStorePath() // CLI's accounts file location
if info, err := os.Stat(accountsPath); err != nil {
if !os.IsNotExist(err) {
log.Fatalf("accounts file exists but is inaccessible: %v", err) // fix perms first
}
} else if info.IsDir() {
log.Fatal("accounts path is a directory; storage is corrupted")
} Type guard
func isLoadAccountsError(err error) bool {
return err != nil && strings.HasPrefix(err.Error(), "error loading accounts:")
} Try / catch
if err := auth.SelectOrSignInOrCreate(); err != nil {
if isLoadAccountsError(err) {
// back up and remove the corrupted accounts file so it is re-created
os.Rename(authStorePath(), authStorePath()+".bak")
err = auth.SelectOrSignInOrCreate()
}
if err != nil {
log.Fatal(err)
}
} Prevention
- Don't run the CLI under sudo if accounts were created as a normal user
- Keep HOME/XDG paths consistent across shells and CI
- Never hand-edit the accounts/auth file while the CLI is running
- Back up the auth store before upgrading the CLI
When it happens
Trigger: Calling SelectOrSignInOrCreate (directly or via promptInitialAuth/signIn) when loadAccounts() fails — e.g. the accounts file is missing in an unexpected way, unreadable due to permissions, corrupted JSON, or the storage directory cannot be accessed.
Common situations: HOME directory misconfigured so auth files land in a nonexistent path; permissions changed by another user or run with sudo vs. normal user; accounts file corrupted by a crashed write or manual edit; upgrading/downgrading CLI changed the storage format.
Related errors
- error signing in to new account: %v
- error selecting account: %v
- error prompting for sign in to new account: %v
- error setting auth: %v
- error writing auth: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/e4644cc276f0a611.
Report an issue: GitHub.