plandex-ai/plandex · error
error writing account credentials: %v
Error message
error writing account credentials: %v
What it means
SetAccountCredentials writes the marshalled creds.json with os.WriteFile using 0600 permissions. This error wraps the write failure — the marshalled credential bytes could not be persisted to disk, so the in-memory cache is not updated and callers can't rely on stored credentials.
Source
Thrown at app/cli/lib/model_credentials.go:583
var cachedAccountCredentials *types.AccountCredentials
func SetAccountCredentials(creds *types.AccountCredentials) error {
if auth.Current == nil {
return fmt.Errorf("no authenticated user")
}
dir := filepath.Join(fs.HomePlandexDir, auth.Current.UserId, auth.Current.OrgId)
err := os.MkdirAll(dir, 0700)
if err != nil {
return fmt.Errorf("error creating account credentials directory: %v", err)
}
path := filepath.Join(dir, "creds.json")
bytes, err := json.MarshalIndent(creds, "", " ")
if err != nil {
return fmt.Errorf("error marshalling account credentials: %v", err)
}
err = os.WriteFile(path, bytes, 0600)
if err != nil {
return fmt.Errorf("error writing account credentials: %v", err)
}
cachedAccountCredentials = creds
return nil
}
func GetAccountCredentials() (*types.AccountCredentials, error) {
if cachedAccountCredentials != nil {
return cachedAccountCredentials, nil
}
if auth.Current == nil {
return nil, fmt.Errorf("no authenticated user")
}
path := filepath.Join(fs.HomePlandexDir, auth.Current.UserId, auth.Current.OrgId, "creds.json")
bytes, err := os.ReadFile(path)View on GitHub (pinned to e2d772072e)
Solutions
- Check permissions on creds.json from the wrapped error path; chmod 0600 or remove the stale file.
- If a directory named creds.json exists, remove it.
- Verify disk space/quota (df -h) and that the volume is writable.
- Re-run the connect/refresh flow after fixing the filesystem issue.
Example fix
// before: blind write
err = os.WriteFile(path, bytes, 0600)
// after: caller-side check
if info, statErr := os.Stat(path); statErr == nil && info.IsDir() {
return fmt.Errorf("%s is a directory; remove it to store credentials", path)
} Defensive patterns
Strategy: validation
Validate before calling
if info, err := os.Stat(path); err == nil {
if info.IsDir() {
return fmt.Errorf("%s is a directory; remove it to store credentials", path)
}
if info.Mode().Perm()&0200 == 0 {
return fmt.Errorf("%s is not writable", path)
}
} Try / catch
if err := SetAccountCredentials(creds); err != nil {
if strings.Contains(err.Error(), "writing account credentials") {
return fmt.Errorf("cannot write creds.json — check permissions/disk space at the reported path: %w", err)
}
return err
} Prevention
- Ensure creds.json is never replaced by a directory (crash-safe writes use temp file + rename).
- Keep ownership of ~/.plandex consistent with the running user.
- Monitor disk quota/space on the home volume.
- Avoid security software that blocks writes to credential files.
When it happens
Trigger: os.WriteFile fails on <HomePlandexDir>/<UserId>/<OrgId>/creds.json: permission denied, path is a directory, disk full, read-only filesystem, or quota exceeded.
Common situations: creds.json exists but is owned by another user or read-only; an earlier crash left a directory named creds.json; antivirus/EDR blocking writes to credential files; disk quota exceeded.
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 creating account credentials directory: %v
- error reading settings-v2.json: %v
- error creating convo message descriptions dir: %v
- error creating results dir: %v
- error creating applies dir: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/47882f21d2a1f40e.
Report an issue: GitHub.