{"record":{"id":"620da123d44b4ee5","repo":"abiosoft/colima","slug":"error-writing-store-file-w","errorCode":null,"errorMessage":"error writing store file: %w","messagePattern":"error writing store file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store/store.go","lineNumber":46,"sourceCode":"\t\treturn s, fmt.Errorf(\"cannot read store file: %w\", err)\n\t}\n\n\tif err := json.Unmarshal(b, &s); err != nil {\n\t\treturn s, fmt.Errorf(\"error unmarshaling store file: %w\", err)\n\t}\n\n\treturn s, nil\n}\n\n// save persists the store.\nfunc save(s Store) error {\n\tb, err := json.MarshalIndent(s, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshaling store: %w\", err)\n\t}\n\n\tif err := os.WriteFile(storeFile(), b, 0o644); err != nil {\n\t\treturn fmt.Errorf(\"error writing store file: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// Set provides an easy way to set a value in the store.\nfunc Set(f func(*Store)) error {\n\ts, err := Load()\n\tif err != nil {\n\t\tlogrus.Debug(\"error loading store: %w\", err)\n\t}\n\n\tf(&s)\n\n\tif err := save(s); err != nil {\n\t\treturn fmt.Errorf(\"error saving store: %w\", err)\n\t}\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/store/store.go#L28-L64","documentation":"os.WriteFile of the marshalled store failed; %w carries the raw OS error. In practice: permission denied when the store file or directory is not writable (classic sudo-mixed-ownership), ENOSPC on a full home partition, or the parent directory disappearing between load and save.","triggerScenarios":"Store path or its directory owned by root after a sudo colima run; home partition out of space; store directory deleted concurrently with the write.","commonSituations":"Alternating sudo and regular colima invocations; disk exhaustion from VM disks and pulled AI models.","solutions":["Fix ownership of the colima config/store directory: chown -R $(id -u):$(id -g) <dir>","Free space on the volume holding the store (df -h) — VM images and models are the usual consumers","Ensure the store's parent directory exists, then retry the operation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify the store path is writable before mutating state\nfunc storeWritable(p string) bool {\n\tif err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {\n\t\treturn false\n\t}\n\tf, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE, 0o644)\n\tif err != nil {\n\t\treturn false\n\t}\n\t_ = f.Close()\n\treturn true\n}","typeGuard":null,"tryCatchPattern":"var perr *fs.PathError\nif errors.As(err, &perr) {\n\tswitch {\n\tcase errors.Is(perr.Err, fs.ErrPermission):\n\t\t// fix ownership of the store dir\n\tcase errors.Is(perr.Err, fs.ErrNotExist):\n\t\t// recreate the parent directory, then retry\n\t}\n}","preventionTips":["Never mix sudo and non-sudo colima runs","Watch home-volume disk usage when pulling multi-GB models","Write stores atomically (temp file + rename) to avoid corrupt partials"],"tags":["filesystem","permissions","disk","persistence","go"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}