plandex-ai/plandex · error
error creating account credentials directory: %v
Error message
error creating account credentials directory: %v
What it means
SetAccountCredentials creates the directory <HomePlandexDir>/<UserId>/<OrgId> with 0700 permissions to hold creds.json. This error wraps os.MkdirAll failure — the credentials file cannot be stored because the per-user credentials directory could not be created.
Source
Thrown at app/cli/lib/model_credentials.go:574
// emoji for satisfied vs missing
func mark(ok bool) string {
if ok {
return "✅"
}
return "❌"
}
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 {View on GitHub (pinned to e2d772072e)
Solutions
- Check that the Plandex home directory (fs.HomePlandexDir) exists and is writable by the current user.
- ls the path from the wrapped error: if a file occupies the directory path, remove/rename it.
- Fix ownership/permissions (chown/chmod) on the home directory, or correct the env var pointing HomePlandexDir at a bad location.
- Ensure the filesystem isn't full or mounted read-only.
Example fix
// before: no pre-check
// after: verify writability before storing creds
if info, err := os.Stat(fs.HomePlandexDir); err == nil && !info.IsDir() {
return fmt.Errorf("%s exists and is not a directory", fs.HomePlandexDir)
} Defensive patterns
Strategy: validation
Validate before calling
if info, err := os.Stat(fs.HomePlandexDir); err == nil && !info.IsDir() {
return fmt.Errorf("%s exists and is not a directory", fs.HomePlandexDir)
}
if f, err := os.OpenFile(fs.HomePlandexDir, os.O_RDWR, 0700); err != nil {
return fmt.Errorf("plandex home dir not writable: %w", err)
} else {
f.Close()
} Try / catch
if err := SetAccountCredentials(creds); err != nil {
if strings.Contains(err.Error(), "creating account credentials directory") {
return fmt.Errorf("cannot create credentials dir — check ownership/permissions on your plandex home directory: %w", err)
}
return err
} Prevention
- Ensure the plandex home directory env/HOME is not overridden to a read-only or foreign-user path.
- Check that no regular file occupies the expected directory path.
- Run the CLI as the same user that owns the home directory.
- Verify free disk space before credential operations.
When it happens
Trigger: os.MkdirAll fails for HomePlandexDir or a subpath: parent directory doesn't exist and can't be created, permission denied, path is a file, disk full, or read-only filesystem.
Common situations: HOME or the Plandex home dir env var overridden to a non-writable path; a regular file occupying the directory path; running as different user than the one who created ~/.plandex with restrictive ownership; read-only container filesystem.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- error writing account credentials: %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/554432a5f27367a4.
Report an issue: GitHub.