plandex-ai/plandex · error
error writing auth: %v
Error message
error writing auth: %v
What it means
After a successful GetOrgSession refresh, RefreshAuth persists the updated auth via writeCurrentAuth (writes auth.json under fs.HomeAuthPath). If persisting fails (I/O error) it is wrapped as this error. The refresh succeeded remotely but could not be saved locally.
Source
Thrown at app/cli/auth/auth.go:132
func RefreshAuth() error {
if Current == nil {
return fmt.Errorf("error refreshing auth: auth not loaded")
}
org, apiErr := apiClient.GetOrgSession()
if apiErr != nil {
return fmt.Errorf("error getting org session: %v", apiErr.Msg)
}
Current.OrgName = org.Name
Current.OrgIsTrial = org.IsTrial
Current.IntegratedModelsMode = org.IntegratedModelsMode
err := writeCurrentAuth()
if err != nil {
return fmt.Errorf("error writing auth: %v", err)
}
return nil
}
View on GitHub (pinned to e2d772072e)
Solutions
- Check disk space (df -h) and free space or quotas
- Verify permissions/ownership of HOME and the auth file path (ls -la ~/.plandex-auth*)
- Ensure HOME points to a writable directory when running in containers/CI
- Inspect the wrapped inner error (%v) — it names the exact OS-level cause
Example fix
// before export HOME=/ro-fs/home # read-only mount // after export HOME=/home/user && plandex sign in
Defensive patterns
Strategy: validation
Validate before calling
if info, err := os.Stat(filepath.Dir(fs.HomeAuthPath)); err != nil || !info.IsDir() {
return fmt.Errorf("auth dir missing or unwritable: %v", err)
}
if err := unix.Access(fs.HomeAuthPath, unix.W_OK); err != nil {
return fmt.Errorf("auth file not writable: %v", err)
} Type guard
func authWritable() bool {
f, err := os.OpenFile(fs.HomeAuthPath, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil { return false }
f.Close()
return true
} Try / catch
if _, err := auth.RefreshAuth(); err != nil {
if strings.Contains(err.Error(), "writing auth") {
// check disk/permissions, then retry once
fmt.Fprintln(os.Stderr, "check disk space and HOME permissions:", err)
_, err = auth.RefreshAuth()
}
if err != nil { term.OutputErrorAndExit("%v", err) }
} Prevention
- Ensure HOME is writable in containers/CI
- Monitor disk space and quotas
- Fix file ownership/permissions after user changes (chown, 0600)
- Don't run the CLI on read-only mounts
When it happens
Trigger: writeCurrentAuth fails writing to HOME: disk full, permission denied on ~/.plandex-auth (or equivalent path), read-only filesystem, or the auth file directory missing.
Common situations: Read-only container/CI filesystem; HOME set to a non-writable path; disk quota exceeded; SELinux/permissions after upgrading the CLI run under a different user; running in a sandbox that blocks writes outside the workspace.
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 storing account: %v
- error loading accounts: %v
- error setting auth: %v
- error writing auth: %v
- refresh failed - save: %w
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/a0d27ab7509382ba.
Report an issue: GitHub.