{"record":{"id":"731b587ac6c50ffc","repo":"abiosoft/colima","slug":"cannot-create-file-s-w","errorCode":null,"errorMessage":"cannot create file '%s': %w","messagePattern":"cannot create file '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/downloader/http.go","lineNumber":122,"sourceCode":"\tvar file *os.File\n\tvar existingSize int64\n\tvar err error\n\n\tif opts.ResumeFromByte > 0 {\n\t\tfile, err = os.OpenFile(opts.DestPath, os.O_WRONLY|os.O_APPEND, 0644)\n\t\tif err != nil {\n\t\t\t// can't resume, start fresh\n\t\t\topts.ResumeFromByte = 0\n\t\t\topts.ExpectedETag = \"\"\n\t\t} else {\n\t\t\texistingSize = opts.ResumeFromByte\n\t\t}\n\t}\n\n\tif file == nil {\n\t\tfile, err = os.Create(opts.DestPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot create file '%s': %w\", opts.DestPath, err)\n\t\t}\n\t}\n\tdefer func() { _ = file.Close() }()\n\n\t// build request\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, opts.URL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid URL '%s': %w\", opts.URL, err)\n\t}\n\treq.Header.Set(\"User-Agent\", h.userAgent)\n\n\t// add Range header for resume\n\tif existingSize > 0 {\n\t\treq.Header.Set(\"Range\", fmt.Sprintf(\"bytes=%d-\", existingSize))\n\t\t// add If-Range with ETag if available for safe resume\n\t\tif opts.ExpectedETag != \"\" {\n\t\t\treq.Header.Set(\"If-Range\", opts.ExpectedETag)\n\t\t}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/util/downloader/http.go#L104-L140","documentation":"Download had no usable resumable partial (none exists, or resume info was invalid), fell through to os.Create(opts.DestPath) on the .downloading cache file, and the OS refused. The wrapped *fs.PathError names the exact path; typical errnos are EACCES, ENOSPC, EROFS, ENOENT (parent dir deleted after MkdirAll).","triggerScenarios":"Cache dir deleted between MkdirAll and os.Create (cleanup race); directory not writable; disk full; DestPath already exists as a directory.","commonSituations":"Disk full when pulling large images; cache-cleaner tools racing the download; root-owned caches directory from earlier sudo runs.","solutions":["Check free space with df -h and free enough for the artifact","Fix ownership/permissions of the cache directory","Retry: transient cleanup races resolve on the next attempt","Exclude the colima cache dir from tmpwatch/cleaner tools"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"dir := filepath.Dir(destPath)\nif err := os.MkdirAll(dir, 0o755); err != nil {\n    return err\n}\nvar st syscall.Statfs_t\nif err := syscall.Statfs(dir, &st); err == nil {\n    free := st.Bavail * uint64(st.Bsize)\n    if free < requiredBytes {\n        return fmt.Errorf(\"insufficient disk space: need %d, free %d\", requiredBytes, free)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check free space before starting downloads that can be gigabytes","Keep cache-cleanup daemons away from the colima cache dir","Monitor disk usage in CI/automation so a full disk fails before, not during, a download"],"tags":["filesystem","disk-space","cache","download"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}