{"record":{"id":"848f1a1d80f17d2c","repo":"lima-vm/lima","slug":"failed-to-create-asif-image-q-w","errorCode":null,"errorMessage":"failed to create ASIF image %#q: %w","messagePattern":"failed to create ASIF image %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imgutil/nativeimgutil/asifutil/asif_darwin.go","lineNumber":24,"sourceCode":"import (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/xml\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/lima-vm/lima/v2/pkg/plist\"\n)\n\n// NewASIF creates a new ASIF image file at the specified path with the given size.\nfunc NewASIF(path string, size int64) error {\n\tcreateArgs := []string{\"image\", \"create\", \"blank\", \"--fs\", \"none\", \"--format\", \"ASIF\", \"--size\", strconv.FormatInt(size, 10), path}\n\tif err := exec.CommandContext(context.Background(), \"diskutil\", createArgs...).Run(); err != nil {\n\t\treturn fmt.Errorf(\"failed to create ASIF image %#q: %w\", path, err)\n\t}\n\tif _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {\n\t\tif _, err2 := os.Stat(path + \".asif\"); !errors.Is(err2, os.ErrNotExist) {\n\t\t\t// diskutil may create the file with .asif suffix\n\t\t\tif err3 := os.Rename(path+\".asif\", path); err3 != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to rename ASIF image from %#q to %#q: %w\", path+\".asif\", path, err3)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// NewAttachedASIF creates a new ASIF image file at the specified path with the given size\n// and attaches it, returning the attached device path and an open file handle.\n// The caller is responsible for detaching the ASIF image device when done.\nfunc NewAttachedASIF(path string, size int64) (string, *os.File, error) {\n\tif err := NewASIF(path, size); err != nil {\n\t\treturn \"\", nil, err","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/imgutil/nativeimgutil/asifutil/asif_darwin.go#L6-L42","documentation":"NewASIF creates a blank ASIF disk image by shelling out to `diskutil image create blank --format ASIF` on macOS. This error wraps a non-zero exit from diskutil during creation. It means diskutil refused or failed to create the image file at the requested path/size.","triggerScenarios":"Calling NewASIF(path, size) (via createDiskMacOSGuest or NewAttachedASIF) when diskutil fails: unsupported macOS version lacking ASIF support, insufficient disk space for the requested size, unwritable target path, or invalid size argument.","commonSituations":"Running on macOS older than the version that supports ASIF images (Tahoe/26+ era diskutil); creating huge images on a nearly full APFS volume; path in a read-only location or with characters diskutil dislikes.","solutions":["Check the wrapped diskutil error (stderr) for the underlying cause (space, permissions, unsupported format)","Verify the macOS version supports `diskutil image create blank --format ASIF` (try the command manually)","Free disk space or reduce the requested image size","Choose a writable, simple path without special characters"],"exampleFix":"// diagnose manually\n// before: opaque failure from NewASIF\n// after\nerr := asifutil.NewASIF(path, size)\nif err != nil {\n    log.Fatalf(\"ASIF creation failed; run: diskutil image create blank --fs none --format ASIF --size %d %q\", size, path)\n}","handlingStrategy":"try-catch","validationCode":"// preflight: check host free space and diskutil ASIF support\nif st, err := os.Stat(filepath.Dir(path)); err != nil || st.Mode().Perm()&0o200 == 0 { return errors.New(\"image directory not writable\") }","typeGuard":null,"tryCatchPattern":"if err := asifutil.NewASIF(path, size); err != nil {\n    var exitErr *exec.ExitError\n    if errors.As(err, &exitErr) { log.Printf(\"diskutil failed: %s\", exitErr.Stderr) }\n    return err\n}","preventionTips":["Free disk space before creating large images","Confirm macOS supports ASIF diskutil image subcommands","Use simple, writable paths for disk images"],"tags":["macos","diskutil","disk-image","asif"],"backgroundTag":"disk-image-create-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}