{"record":{"id":"c4e56b129be716ea","repo":"abiosoft/colima","slug":"cannot-restart-vm-not-previously-started","errorCode":null,"errorMessage":"cannot restart, VM not previously started","messagePattern":"cannot restart, VM not previously started","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/lima.go","lineNumber":255,"sourceCode":"\ta := l.Init(ctx)\n\n\tif util.MacOS() {\n\t\tconf, _ := configmanager.LoadInstance()\n\t\ta.Retry(\"\", time.Second*1, 10, func(retryCount int) error {\n\t\t\treturn l.daemon.Stop(ctx, conf)\n\t\t})\n\t}\n\n\ta.Add(func() error {\n\t\treturn l.host.Run(limactl, \"delete\", \"--force\", config.CurrentProfile().ID)\n\t})\n\n\treturn a.Exec()\n}\n\nfunc (l limaVM) Restart(ctx context.Context) error {\n\tif l.conf.Empty() {\n\t\treturn fmt.Errorf(\"cannot restart, VM not previously started\")\n\t}\n\n\tif err := l.Stop(ctx, false); err != nil {\n\t\treturn err\n\t}\n\n\t// minor delay to prevent possible race condition.\n\ttime.Sleep(time.Second * 2)\n\n\tif err := l.Start(ctx, l.conf); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (l limaVM) Host() environment.HostActions {\n\treturn l.host","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/lima.go#L237-L273","documentation":"limaVM.Restart refuses to run when the in-memory config for the profile is empty, because restart replays the previous start configuration (Stop then Start with l.conf). An empty config means Colima has no record of how the VM was started in this invocation, so it cannot safely restart. The config is normally loaded from the persisted Lima/Colima profile state before Restart is called.","triggerScenarios":"Invoking restart through an API path that never loaded the profile config (fresh limaVM instance without prior Start/Load); profile state file missing/corrupt so config parses as empty; calling Restart on a profile that was deleted.","commonSituations":"Programmatic use of the environment package constructing a new limaVM without loading state; users running `colima restart` after manually deleting state under ~/.colima; bugs in wrappers that skip initialization.","solutions":["For CLI users: run `colima stop && colima start` instead, or simply retry `colima restart` which loads state through the normal command path.","Ensure the profile's state/Lima config file exists (not manually deleted); if gone, recreate with `colima start`.","For API users: call the profile/config load step (the same one the restart command uses) before Restart, or Start the VM first.","Verify you are targeting an existing profile name; a typo'd profile has no state and hits this path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// CLI users: ensure profile has state before restart\n// `colima status -p <profile>` should report created/running\n// API users: load persisted config before Restart (the restart command path does this)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-delete files under ~/.colima/_lima/<profile>","Use colima stop/start when restart errors","Verify profile name spelling in scripts"],"tags":["restart","lifecycle","state","colima","profile"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}