{"record":{"id":"d9c1213de5732012","repo":"lima-vm/lima","slug":"failed-to-stop-vm-after-installation-w","errorCode":null,"errorMessage":"failed to stop VM after installation: %w","messagePattern":"failed to stop VM after installation: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/vz/vm_darwin_arm64.go","lineNumber":168,"sourceCode":"\t\t\t\tlogrus.WithError(ctx.Err()).Info(\"macOS installer exited\")\n\t\t\t\tbar.SetCurrent(barResolution)\n\t\t\t\treturn\n\t\t\tcase <-ticker.C:\n\t\t\t\tprogress := installer.FractionCompleted() * barResolution\n\t\t\t\tbar.SetCurrent(int64(progress))\n\t\t\t}\n\t\t}\n\t}()\n\n\terr = installer.Install(ctx)\n\tbar.Finish()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstopped, err := vm.RequestStop()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to stop VM after installation: %w\", err)\n\t}\n\tif !stopped {\n\t\tlogrus.WithError(err).Warn(\"VM did not stop after installation\")\n\t\tif err = vm.Stop(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to force stop VM after installation: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":150,"sourceCodeEnd":178,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/vz/vm_darwin_arm64.go#L150-L178","documentation":"After the macOS installer VM finishes (vm.RequestStop path), installMacOS stops the VM. If vm.RequestStop() returns an error, this wrapped error is thrown, meaning the Virtualization framework refused or failed the graceful stop request.","triggerScenarios":"vm.RequestStop() on the freshly installed macOS VM returns a non-nil error during `limactl start` of a VZ macOS guest (install phase).","commonSituations":"Virtualization.framework state inconsistency after installation; VM already halted or crashed so the stop request fails; macOS version-specific framework bugs.","solutions":["Retry `limactl start <instance>` — the install step is usually skippable/resumable","If the VM is actually gone, delete and recreate the instance: `limactl delete <name> --force`","Update macOS to get Virtualization.framework fixes","Inspect the wrapped error for the underlying framework cause"],"exampleFix":"// before\n$ limactl start macos-test  # fails stopping installer VM\n// after\n$ limactl delete macos-test --force\n$ limactl start macos-test","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := start(); err != nil && strings.Contains(err.Error(), \"failed to stop VM after installation\") {\n    // VM state may be inconsistent: force delete and retry\n    exec.Command(\"limactl\", \"delete\", instName, \"--force\").Run()\n    err = start()\n}","preventionTips":["Don't interrupt the macOS install phase once started","Keep macOS host updated","Check `limactl list` state before retrying a start"],"tags":["vz","vm-lifecycle","macos-guest","install"],"backgroundTag":"vm-stop-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}