plandex-ai/plandex · error
error writing auth: %v
Error message
error writing auth: %v
What it means
After storing the account, setAuth writes the full current auth (token etc.) to fs.HomeAuthPath via writeCurrentAuth, wrapping any failure in this error. The account was saved but the session auth file could not be written, so sign-in is not persisted. Note writeCurrentAuth also emits this prefix for "auth not loaded" and marshal failures.
Source
Thrown at app/cli/auth/state.go:48
return nil, fmt.Errorf("error unmarshalling accounts.json: %v", err)
}
return accounts, nil
}
func setAuth(auth *shared.ClientAuth) error {
err := storeAccount(&auth.ClientAccount)
if err != nil {
return fmt.Errorf("error storing account: %v", err)
}
Current = auth
err = writeCurrentAuth()
if err != nil {
return fmt.Errorf("error writing auth: %v", err)
}
return nil
}
func storeAccount(toStore *shared.ClientAccount) error {
accounts, err := loadAccounts()
if err != nil {
return fmt.Errorf("error loading accounts: %v", err)
}
found := false
for i, account := range accounts {
if account.UserId == toStore.UserId {
accounts[i] = toStore
found = true
breakView on GitHub (pinned to e2d772072e)
Solutions
- Fix ownership/permissions on ~/.plandex and the auth file (chown/chmod)
- Ensure HOME is set to a writable directory
- Free disk space if ENOSPC
- Sign in again once the filesystem issue is resolved
Example fix
// before error writing auth: open ~/.plandex/auth.json: read-only file system // after $ export HOME=/home/user # point HOME at a writable dir $ plandex-cli sign-in
Defensive patterns
Strategy: try-catch
Validate before calling
// confirm the auth file location is writable before sign-in
if err := os.WriteFile(fs.HomeAuthPath+".wtest", []byte(""), 0o600); err != nil {
return fmt.Errorf("auth file not writable: %v", err)
}
os.Remove(fs.HomeAuthPath + ".wtest") Try / catch
if err := setAuth(auth); err != nil {
if strings.Contains(err.Error(), "error writing auth") {
// fix ~/.plandex permissions / HOME / disk, then sign in again
}
return err
} Prevention
- Ensure HOME points to a writable directory (watch containers/read-only images)
- Avoid sudo runs that root-own auth.json
- Keep disk space available for token refreshes
- Re-authenticate promptly if sign-in persistence failed
When it happens
Trigger: setAuth calls writeCurrentAuth after setting Current; os.WriteFile(fs.HomeAuthPath, ...) fails — permission denied, read-only filesystem, disk full — or (rarely) marshal of Current fails.
Common situations: ~/.plandex/auth.json root-owned after sudo usage; read-only HOME (containers, immutable images); disk full; HOME unset or pointing somewhere unwritable.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- error loading accounts: %v
- error setting auth: %v
- error writing auth: %v
- error writing auth: %v
- error reading accounts.json: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/ec76618722ce478a.
Report an issue: GitHub.