{"record":{"id":"31a440ce2a5ad0b1","repo":"abiosoft/colima","slug":"error-during-teardown-of-vm-w","errorCode":null,"errorMessage":"error during teardown of vm: %w","messagePattern":"error during teardown of vm: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/app.go","lineNumber":277,"sourceCode":"\tif c.guest.Running(ctx) {\n\t\tcontainers, err := c.currentContainerEnvironments(ctx)\n\t\tif err != nil {\n\t\t\tlog.Warnln(fmt.Errorf(\"error retrieving runtimes: %w\", err))\n\t\t}\n\t\tfor _, cont := range containers {\n\t\t\tlog := log.WithField(\"context\", cont.Name())\n\t\t\tlog.Println(\"deleting ...\")\n\n\t\t\tif err := cont.Teardown(ctx); err != nil {\n\t\t\t\t// failure here is not fatal\n\t\t\t\tlog.Warnln(fmt.Errorf(\"error during teardown of %s: %w\", cont.Name(), err))\n\t\t\t}\n\t\t}\n\t}\n\n\t// teardown vm\n\tif err := c.guest.Teardown(ctx); err != nil {\n\t\treturn fmt.Errorf(\"error during teardown of vm: %w\", err)\n\t}\n\n\t// delete configs\n\tif err := configmanager.Teardown(); err != nil {\n\t\treturn fmt.Errorf(\"error deleting configs: %w\", err)\n\t}\n\n\t// delete runtime disk if disk in use and data deletion is requested\n\tif diskInUse && data {\n\t\tlog.Println(\"deleting container data\")\n\t\tif err := limautil.DeleteDisk(); err != nil {\n\t\t\treturn fmt.Errorf(\"error deleting container data: %w\", err)\n\t\t}\n\n\t\tif err := store.Reset(); err != nil {\n\t\t\tlog.Trace(\"error resetting store: %w\", err)\n\t\t}\n\t}","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/app/app.go#L259-L295","documentation":"The Lima instance teardown (limactl delete) failed and the error is returned: this is the fatal step of `colima delete`. The VM image and instance directory under ~/.lima/<profile> were not removed.","triggerScenarios":"`colima delete` when limactl cannot remove the instance: VM still marked running, lima state files inconsistent after a crash, or files under ~/.lima held open by another process.","commonSituations":"Deleting right after a failed stop; a wedged qemu process keeping the instance directory busy; permissions changed under ~/.lima after running colima with sudo.","solutions":["Retry with force: `colima delete --force`","Drive lima directly: `limactl delete -f colima` for the default profile","Ensure no qemu/vz process for the profile survives (`pgrep -af qemu`), kill it, then delete again","Last resort: `rm -rf ~/.lima/colima` (and the profile's colima config dir) once no process uses it"],"exampleFix":"# before\ncolima delete\n# error: error during teardown of vm: ...\n\n# after\ncolima delete --force || limactl delete -f colima","handlingStrategy":"retry","validationCode":"// ensure the VM is stopped cleanly before delete\nif err := a.Stop(true); err != nil {\n    // proceed, but plan for force teardown: a.Delete(false, true)\n}","typeGuard":null,"tryCatchPattern":"if err := a.Delete(false, false); err != nil {\n    if strings.Contains(err.Error(), \"error during teardown of vm\") {\n        return a.Delete(false, true) // force teardown\n    }\n}","preventionTips":["Stop cleanly before delete","Never delete ~/.lima files while a VM runs","Keep ~/.lima user-owned to avoid sudo artifacts"],"tags":["delete","teardown","lima","vm"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}