{"record":{"id":"cc4a4870ea64c316","repo":"lima-vm/lima","slug":"failed-to-convert-q-to-q-w","errorCode":null,"errorMessage":"failed to convert %#q to %#q: %w","messagePattern":"failed to convert %#q to %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driverutil/disk.go","lineNumber":114,"sourceCode":"\t\t\treturn fmt.Errorf(\"failed to create disk %#q: %w\", diskPath, err)\n\t\t}\n\t} else {\n\t\tformat, err := nativeimgutil.DetectFormat(imagePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Resize handled by prepareDisk() after CreateDisk()\n\t\tif format == string(diskImageFormat) {\n\t\t\tif err = os.Rename(imagePath, diskPath); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to rename %#q to %#q: %w\", imagePath, diskPath, err)\n\t\t\t}\n\t\t\tif err := os.Chmod(diskPath, 0o644); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to chmod %#q: %w\", diskPath, err)\n\t\t\t}\n\t\t} else {\n\t\t\tif err := diskUtil.Convert(ctx, diskImageFormat, imagePath, diskPath, &diskSizeInBytes, false); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to convert %#q to %#q: %w\", imagePath, diskPath, err)\n\t\t\t}\n\t\t\tos.Remove(imagePath)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":96,"sourceCodeEnd":121,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driverutil/disk.go#L96-L121","documentation":"EnsureDisk wraps a failure from diskUtil.Convert, which shells out to an image tool (qemu-img style via proxyimgutil) to convert the downloaded image to the requested disk format and size. Lima throws this when the conversion tool fails or is unavailable. The wrapped error contains the tool's own message.","triggerScenarios":"EnsureDisk detects the image format differs from the requested diskImageFormat and calls Convert; conversion fails because qemu-img (or equivalent) is not installed, the source image is corrupt, the target size is invalid, or disk is full.","commonSituations":"Minimal host without qemu-utils installed; downloaded image truncated/corrupt (interrupted download); disk size string parsed to 0 or too large for free space; incompatible source format the proxy tool cannot handle.","solutions":["Read the wrapped error for the underlying tool message; install qemu-utils (or the platform equivalent) if it is a missing-binary error","Re-download the image; verify it with nativeimgutil.DetectFormat or qemu-img info to rule out corruption","Check free disk space in instDir and use a valid diskSize value","Set the instance's vmType/image format so requested diskImageFormat matches the downloaded image format, avoiding conversion entirely"],"exampleFix":"// before: conversion fails with exec: \"qemu-img\": executable file not found\n// after: install the tool\n//   Debian/Ubuntu: apt-get install qemu-utils\n//   macOS: brew install qemu","handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"qemu-img\"); err != nil {\n    return fmt.Errorf(\"qemu-img required for image conversion: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := driverutil.EnsureDisk(ctx, instDir, diskSize, format); err != nil {\n    if strings.Contains(err.Error(), \"failed to convert\") {\n        // check free space, tool availability, then retry once after re-download\n    }\n    return err\n}","preventionTips":["Install qemu-utils before first `limactl start`","Verify downloaded image integrity (size/checksum) when on flaky networks","Keep free disk space comfortably above the requested disk size"],"tags":["disk-image","qemu-img","conversion"],"backgroundTag":"image-conversion-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}