{"record":{"id":"f30a3e64da0d3871","repo":"plandex-ai/plandex","slug":"error-writing-current-plan-v","errorCode":null,"errorMessage":"error writing current plan: %v","messagePattern":"error writing current plan: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/plans.go","lineNumber":52,"sourceCode":"\n\tif currentPlanSettingsByAccount == nil {\n\t\tcurrentPlanSettingsByAccount = &types.CurrentPlanSettingsByAccount{}\n\t}\n\n\tsettings := types.CurrentPlanSettings{\n\t\tId: id,\n\t}\n\n\t(*currentPlanSettingsByAccount)[auth.Current.UserId] = &settings\n\n\tbytes, err = json.Marshal(currentPlanSettingsByAccount)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshalling current plan: %v\", err)\n\t}\n\n\terr = os.WriteFile(HomeCurrentPlanPath, bytes, 0644)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing current plan: %v\", err)\n\t}\n\n\tCurrentPlanId = id\n\n\treturn nil\n}\n\nfunc ClearCurrentPlan() error {\n\tif fs.HomePlandexDir == \"\" {\n\t\treturn fmt.Errorf(\"HomePlandexDir not set\")\n\t}\n\n\tif CurrentProjectId == \"\" || HomeCurrentPlanPath == \"\" {\n\t\treturn fmt.Errorf(\"no current project\")\n\t}\n\n\tvar currentPlanSettingsByAccount *types.CurrentPlanSettingsByAccount\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/plans.go#L34-L70","documentation":"The final step of WriteCurrentPlan persists the updated current-plan map to ~/.plandex/current-plans-v2.json with 0644 permissions. If os.WriteFile fails, the new current plan id is not recorded (CurrentPlanId is not updated) and this error wraps the OS-level reason.","triggerScenarios":"os.WriteFile(HomeCurrentPlanPath, bytes, 0644) fails — disk full, ~/.plandex missing or unwritable, permission denied on the existing file, or the target path is a directory. Raised from 'plandex cd' / 'plandex new'.","commonSituations":"Full disk (ENOSPC); ~/.plandex deleted or recreated with wrong ownership while the CLI runs under a different user; read-only home filesystem (diskless/NFS ro); antivirus or sandbox blocking writes to dotfiles.","solutions":["Check free space: df -h ~ and clean up if the disk is full.","Check ownership/permissions of ~/.plandex and the file: ls -ld ~/.plandex ~/.plandex/current-plans-v2.json; chown/chmod as needed.","If the path is a directory or bad symlink, remove it so WriteFile can create the file.","Re-run the command after fixing the filesystem; the write is idempotent."],"exampleFix":"// before: no space left on device\nplandex new\n// error writing current plan: open ...: no space left on device\n\n// after: free space and retry\ndf -h ~  # confirm space recovered\nplandex new","handlingStrategy":"validation","validationCode":"home := os.Getenv(\"HOME\")\nif free, err := diskFree(home); err == nil && free < 1<<20 {\n\treturn fmt.Errorf(\"less than 1MB free in %s; plandex write will fail\", home)\n}\nif fi, err := os.Stat(filepath.Join(home, \".plandex\")); err != nil || !fi.IsDir() {\n\treturn fmt.Errorf(\"~/.plandex missing or not a directory\")\n}","typeGuard":"func canWriteHomeState() bool {\n\tf, err := os.OpenFile(filepath.Join(os.Getenv(\"HOME\"), \".plandex\", \".probe\"), os.O_CREATE|os.O_WRONLY, 0644)\n\tif err != nil { return false }\n\tf.Close(); os.Remove(f.Name())\n\treturn true\n}","tryCatchPattern":"if err := lib.WriteCurrentPlan(id); err != nil {\n\tif strings.Contains(err.Error(), \"error writing current plan\") {\n\t\t// check ENOSPC/EACCES in the wrapped message and remediate before retrying\n\t}\n}","preventionTips":["Monitor free disk space on the home partition.","Run all plandex commands as the same (non-root) user.","Keep ~/.plandex out of read-only mounts and restricted sandboxes.","After any failure, verify the state file before retrying to avoid duplicate state."],"tags":["cli","filesystem","write-error","permissions","disk-full"],"backgroundTag":"permission-denied","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}