{"record":{"id":"f52ae7a5bcb0a45a","repo":"lima-vm/lima","slug":"failed-to-convert-image-to-raw-w","errorCode":null,"errorMessage":"failed to convert image to raw: %w","messagePattern":"failed to convert image to raw: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/downloader/downloader.go","lineNumber":437,"sourceCode":"\t}\n\n\t// If the driver cannot use the format we just downloaded, save a converted\n\t// raw copy at <shad>/imgconv/raw, keeping the original <shad>/data as-is.\n\t//\n\t// Gated on WithImageFormats() (the caller's signal that this is a VM disk\n\t// image) and on the file not being an ISO 9660 image.\n\tif len(o.supportedImageFormats) > 0 {\n\t\tisISO, err := iso9660util.IsISO9660(shadData)\n\t\tif err != nil {\n\t\t\tlogrus.WithError(err).Debugf(\"Skipping cache image conversion for %q (unable to check ISO9660)\", shadData)\n\t\t} else if !isISO {\n\t\t\tformat, err := nativeimgutil.DetectFormat(shadData)\n\t\t\tif err != nil {\n\t\t\t\tlogrus.WithError(err).Debugf(\"Skipping cache image conversion for %q (unable to detect format)\", shadData)\n\t\t\t} else if !slices.Contains(o.supportedImageFormats, format) {\n\t\t\t\tconverted, rawDigest, err := ensureRawInCache(ctx, shadData, format, o.expectedDigest)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to convert image to raw: %w\", err)\n\t\t\t\t} else if converted != \"\" {\n\t\t\t\t\tshadData = converted\n\t\t\t\t\tif o.expectedDigest != \"\" {\n\t\t\t\t\t\to.expectedDigest = rawDigest\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// no need to pass the digest to copyLocal(), as we already verified the digest\n\tif err := copyLocal(ctx, localPath, shadData, ext, o.decompress, \"\", \"\"); err != nil {\n\t\treturn nil, err\n\t}\n\tres := &Result{\n\t\tStatus:          StatusDownloaded,\n\t\tCachePath:       shadData,\n\t\tLastModified:    readTime(shadTime),","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/downloader/downloader.go#L419-L455","documentation":"During fetch, the downloaded image's format did not match the supported formats, so ensureRawInCache was invoked to convert it to raw; that conversion failed, and the underlying error is wrapped with this message. The download cannot satisfy the caller's format requirement.","triggerScenarios":"Download of a qcow2/vdi/etc image where nativeimgutil.DetectFormat succeeds but the format is unsupported, and ensureRawInCache fails (disk full during conversion, DiskUtil.Convert error, unsupported source format for the converter).","commonSituations":"Downloading VM images that need qemu-img-style conversion on hosts lacking the backing tool (e.g. qemu-img not installed or virtualization framework restrictions); cache dir out of space.","solutions":["Read the wrapped %w error to identify the conversion failure root cause (missing tool vs disk space).","Free space in the cache directory (df -h; prune ~/.cache/lima).","Install/repair the image conversion backend (e.g. qemu-img) or download an image already in the supported raw format."],"exampleFix":"// before: conversion fails because qemu-img missing\n$ brew install qemu   # or apt install qemu-utils\n// then retry the download; conversion succeeds","handlingStrategy":"try-catch","validationCode":"if format, err := nativeimgutil.DetectFormat(localFile); err == nil && !slices.Contains(supportedFormats, format) {\n    log.Warnf(\"image %s (%s) will require raw conversion\", localFile, format)\n}","typeGuard":null,"tryCatchPattern":"res, err := d.Download(ctx, local, url)\nif err != nil && strings.Contains(err.Error(), \"failed to convert image to raw\") {\n    // inspect wrapped cause; free cache space or install converter, then retry\n}","preventionTips":["Download images already in the supported raw format when possible.","Keep the cache volume with ample free space for raw conversions.","Ensure conversion tooling (qemu-img equivalents) is installed on the host."],"tags":["downloader","image-conversion","raw-format","cache"],"backgroundTag":"image-conversion-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}