{"record":{"id":"1795261ce7e0f9ab","repo":"abiosoft/colima","slug":"error-creating-directory-s-w","errorCode":null,"errorMessage":"error creating directory '%s': %w","messagePattern":"error creating directory '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/file.go","lineNumber":28,"sourceCode":"\t\"strings\"\n\t\"time\"\n\n\t\"github.com/abiosoft/colima/environment\"\n)\n\nfunc (l limaVM) Read(fileName string) (string, error) {\n\ts, err := l.RunOutput(\"sudo\", \"cat\", fileName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot read file '%s': %w\", fileName, err)\n\t}\n\treturn s, err\n}\n\nfunc (l *limaVM) Write(fileName string, body []byte) error {\n\tvar stdin = bytes.NewReader(body)\n\tdir := filepath.Dir(fileName)\n\tif err := l.RunQuiet(\"sudo\", \"mkdir\", \"-p\", dir); err != nil {\n\t\treturn fmt.Errorf(\"error creating directory '%s': %w\", dir, err)\n\t}\n\treturn l.RunWith(stdin, nil, \"sudo\", \"sh\", \"-c\", \"cat > \"+fileName)\n}\n\nfunc (l *limaVM) Stat(fileName string) (os.FileInfo, error) {\n\treturn newFileInfo(l, fileName)\n}\n\nvar _ os.FileInfo = (*fileInfo)(nil)\n\ntype fileInfo struct {\n\tisDir   bool\n\tmodTime time.Time\n\tmode    fs.FileMode\n\tname    string\n\tsize    int64\n}\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/file.go#L10-L46","documentation":"limaVM.Write first creates the target's parent directory with `sudo mkdir -p <dir>` inside the guest before piping bytes via `cat > file`. This error wraps a failure of that mkdir step: sudo unavailable, read-only mount for that path, invalid directory name (e.g. paths with characters the guest shell mishandles), or SSH execution failure. The subsequent file write gets a different (unwrapped) error path.","triggerScenarios":"Writing guest files into paths under read-only mounts (e.g. /proc-style or bind-mounted read-only volumes); guest still booting; malformed absolute paths (empty dir, trailing slashes on root); concurrent guest operations breaking sudo.","commonSituations":"Certificate and config deployment during start; custom scripts writing to unusual guest locations; broken guests after forced shutdowns.","solutions":["Validate the target directory makes sense (absolute, not under a read-only mount) before writing.","Verify guest health: `colima ssh -- sudo mkdir -p <dir>` manually to see the raw failure.","Retry after stop/start for transient states.","Recreate the VM if the guest userspace is corrupted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// sanity-check target before write\nif !filepath.IsAbs(fileName) { return fmt.Errorf(\"guest path must be absolute: %s\", fileName) }\nif isReadOnlyGuestMount(filepath.Dir(fileName)) { return fmt.Errorf(\"refusing write to read-only dir: %s\", filepath.Dir(fileName)) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute guest paths","Avoid writing under read-only mounts","Verify guest health with colima ssh before automated writes"],"tags":["file-write","guest","ssh","filesystem","colima"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}