{"record":{"id":"65539c7ee6a74951","repo":"lima-vm/lima","slug":"failed-to-write-raw-digest-file-w","errorCode":null,"errorMessage":"failed to write raw digest file: %w","messagePattern":"failed to write raw digest file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/downloader/downloader.go","lineNumber":516,"sourceCode":"\t}\n\tif err := os.Rename(rawPathTmp, rawImgConvPath); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to replace original with raw image: %w\", err)\n\t}\n\n\talgo := digest.Canonical\n\tif originalDigest != \"\" {\n\t\talgo = originalDigest.Algorithm()\n\t}\n\trawDigest, err := calculateFileDigest(rawImgConvPath, algo)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to calculate digest of raw image: %w\", err)\n\t}\n\n\trawDigestPath := filepath.Join(imgConvPath, \"raw.digest\")\n\trawDigestPathTmp := rawDigestPath + \".tmp\"\n\tdefer os.Remove(rawDigestPathTmp)\n\tif err := os.WriteFile(rawDigestPathTmp, []byte(rawDigest.String()), 0o644); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to write raw digest file: %w\", err)\n\t}\n\tif err := os.Remove(rawDigestPath); err != nil && !errors.Is(err, os.ErrNotExist) {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to remove stale raw digest file %q: %w\", rawDigestPath, err)\n\t}\n\tif err := os.Rename(rawDigestPathTmp, rawDigestPath); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to rename raw digest file: %w\", err)\n\t}\n\n\treturn rawImgConvPath, rawDigest, nil\n}\n\nfunc calculateFileDigest(path string, algo digest.Algorithm) (digest.Digest, error) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer f.Close()\n","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/downloader/downloader.go#L498-L534","documentation":"The computed raw digest is first written to imgconv/raw.digest.tmp, then renamed to raw.digest for atomicity. If os.WriteFile cannot create/write the tmp file, this error is returned. A failing write here almost always means the cache directory is unwritable or the disk is full.","triggerScenarios":"os.WriteFile(rawDigestPathTmp, ..., 0o644) fails with ENOSPC (disk full), EACCES (imgconv dir not writable by current user), or ENOENT (imgconv dir deleted mid-run).","commonSituations":"Host cache volume out of space after writing a large raw image; cache dir owned by root while lima runs unprivileged; another process wiped imgconv during conversion.","solutions":["Free disk space on the cache volume (df -h) — raw conversion can consume large amounts","Fix ownership/permissions of the cache directory so the running user can write (chown -R)","Delete the affected cache entry and retry the download from scratch","Point LIMA_HOME/cache at a volume with sufficient free space"],"exampleFix":"// before\n# df -h ~/.lima/_cache  -> 100% used\n// after\n$ df -h ~/.lima/_cache  # ensure free space, or:\n$ limactl rm <instance> && rm -rf ~/.lima/_cache/download/by-url-sha256/<hash>","handlingStrategy":"validation","validationCode":"// ensure enough free space before downloading/converting large images\nvar st unix.Statfs_t\nif err := unix.Statfs(cacheDir, &st); err == nil {\n    avail := int64(st.Bavail) * st.Bsize\n    if avail < 20<<30 { return fmt.Errorf(\"only %d bytes free in cache volume\", avail) }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to write raw digest file\") {\n    // check ENOSPC vs EACCES and act accordingly\n    return fmt.Errorf(\"cache volume full or unwritable; free space or fix perms: %w\", err)\n}","preventionTips":["Keep at least several GB free on the cache volume — raw conversion roughly doubles image footprint","Keep cache ownership consistent (single user)","Alert/monitor on disk usage of LIMA_HOME","Clean stale downloads periodically (limactl or manual rm of by-url-sha256 entries)"],"tags":["go","filesystem","cache","disk-space"],"backgroundTag":"no-space-left-on-device","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}