{"record":{"id":"3d49fe0232b75587","repo":"lima-vm/lima","slug":"failed-to-convert-q-to-raw-w","errorCode":null,"errorMessage":"failed to convert %q to raw: %w","messagePattern":"failed to convert %q to raw: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/downloader/downloader.go","lineNumber":476,"sourceCode":"\t}\n\treturn res, nil\n}\n\n// ensureRawInCache converts any image to raw and places it in the cache(imgconv/raw). It also creates a\n// digest file for the raw image(imgconv/raw.digest). Returns the converted image path, the raw digest, and any error.\nfunc ensureRawInCache(ctx context.Context, imagePath, format string, originalDigest digest.Digest) (string, digest.Digest, error) {\n\timgConvPath := filepath.Join(filepath.Dir(imagePath), \"imgconv\")\n\tif err := os.MkdirAll(imgConvPath, 0o700); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\trawImgConvPath := filepath.Join(imgConvPath, \"raw\")\n\n\tlogrus.Infof(\"Converting %s image to raw sparse format in cache: %q\", format, rawImgConvPath)\n\trawPathTmp := filepath.Join(imgConvPath, \"raw.tmp\")\n\tdefer os.Remove(rawPathTmp)\n\tdiskUtil := proxyimgutil.NewDiskUtil(ctx)\n\tif err := diskUtil.Convert(ctx, raw.Type, imagePath, rawPathTmp, nil, false); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to convert %q to raw: %w\", imagePath, err)\n\t}\n\n\t// Ensure the image is sparse to save cache space.\n\trawTmpF, err := os.OpenFile(rawPathTmp, os.O_RDWR, 0o644)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to open raw tmp file %q: %w\", rawPathTmp, err)\n\t}\n\tfi, err := rawTmpF.Stat()\n\tif err != nil {\n\t\t_ = rawTmpF.Close()\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to stat raw tmp file %q: %w\", rawPathTmp, err)\n\t}\n\tif err := diskUtil.MakeSparse(ctx, rawTmpF, fi.Size()); err != nil {\n\t\tlogrus.WithError(err).Warnf(\"Failed to make %q sparse (non-fatal)\", rawPathTmp)\n\t}\n\tif err := rawTmpF.Close(); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to close raw tmp file %q: %w\", rawPathTmp, err)\n\t}","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/downloader/downloader.go#L458-L494","documentation":"ensureRawInCache converts a cached image to raw sparse format via proxyimgutil's DiskUtil.Convert; any failure from the converter is wrapped as this error, naming the source image path. It is the core \"conversion step failed\" error of the raw-image cache pipeline.","triggerScenarios":"DiskUtil.Convert fails inside ensureRawInCache (called from getCached or fetch) — source image unreadable, conversion backend unavailable, output volume full (raw.tmp write), or the image format cannot be converted by the selected raw.Type converter.","commonSituations":"Cache dir on a full or read-only volume; exotic/encrypted disk images the converter rejects; partial/corrupt source image in cache from an earlier failed download.","solutions":["Inspect the wrapped %w error for the converter's own message (e.g. 'no space left on device').","Free space in the cache/imgConv directory and remove stale raw.tmp files.","Delete the corrupt cached source image and re-download.","Install or update the conversion tooling the converter depends on."],"exampleFix":"// before: ENOSPC during conversion\n$ df -h ~/.cache/lima && du -sh ~/.cache/lima/*\n$ rm -f ~/.cache/lima/images/*/raw.tmp\n// after: retry download; conversion completes","handlingStrategy":"try-catch","validationCode":"if free, err := disk.Free(cacheDir); err == nil && free < minRequiredBytes {\n    return errors.New(\"cache volume too low on space for raw conversion\")\n}","typeGuard":null,"tryCatchPattern":"res, err := d.Download(ctx, local, url)\nvar convErr *fmt.WrapError // inspect via errors.Unwrap chain\nif err != nil && strings.Contains(err.Error(), \"failed to convert\") {\n    if wrapped := errors.Unwrap(errors.Unwrap(err)); wrapped != nil {\n        log.Errorf(\"conversion root cause: %v\", wrapped)\n    }\n}","preventionTips":["Monitor free space on the CacheDir volume before large image downloads.","Purge failed conversions (raw.tmp leftovers) after aborted runs.","Verify image integrity/checksums to avoid converting corrupt sources."],"tags":["downloader","image-conversion","raw-format","disk-space"],"backgroundTag":"image-conversion-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}