{"record":{"id":"f11de265bc6e4e16","repo":"lima-vm/lima","slug":"failed-to-create-driver-instance-w-f11de2","errorCode":null,"errorMessage":"failed to create driver instance: %w","messagePattern":"failed to create driver instance: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/snapshot/snapshot.go","lineNumber":19,"sourceCode":"// SPDX-FileCopyrightText: Copyright The Lima Authors\n// SPDX-License-Identifier: Apache-2.0\n\npackage snapshot\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/lima-vm/lima/v2/pkg/driver\"\n\t\"github.com/lima-vm/lima/v2/pkg/driverutil\"\n\t\"github.com/lima-vm/lima/v2/pkg/limatype\"\n\t\"github.com/lima-vm/lima/v2/pkg/limayaml\"\n)\n\nfunc Del(ctx context.Context, inst *limatype.Instance, tag string) error {\n\tlimaDriver, err := createConfiguredDriver(ctx, inst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create driver instance: %w\", err)\n\t}\n\n\treturn limaDriver.DeleteSnapshot(ctx, tag)\n}\n\nfunc Save(ctx context.Context, inst *limatype.Instance, tag string) error {\n\tlimaDriver, err := createConfiguredDriver(ctx, inst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create driver instance: %w\", err)\n\t}\n\treturn limaDriver.CreateSnapshot(ctx, tag)\n}\n\nfunc Load(ctx context.Context, inst *limatype.Instance, tag string) error {\n\tlimaDriver, err := createConfiguredDriver(ctx, inst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create driver instance: %w\", err)\n\t}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/snapshot/snapshot.go#L1-L37","documentation":"snapshot.Del instantiates the instance's configured driver (via driverutil.CreateConfiguredDriver) before delegating to the driver's DeleteSnapshot. When driver construction fails — wrong/missing driver, failed instance config validation after filling defaults, or driver initialization errors — the failure is wrapped as \"failed to create driver instance\". The snapshot was not deleted; the operation aborts before touching the VM.","triggerScenarios":"Calling snapshot.Del (limactl snapshot delete) when CreateConfiguredDriver returns an error: the instance's recorded driver name has no registered driver binary (external driver missing), the instance YAML fails limayaml.Validate after defaults are filled, or the driver's own initialization (e.g. reading instance state) fails.","commonSituations":"Deleting snapshots of an instance created with an external driver that was since uninstalled or is not on the driver path; instance directory whose lima.yaml was hand-edited into an invalid state; running the command against an instance whose config predates a schema change.","solutions":["Read the wrapped cause in the error chain; if it says the driver is unknown/missing, reinstall the external driver or ensure it is discoverable (LIMA_DRIVERS / libexec dir, named lima-driver-<name>).","Run `limactl validate <instance-config>` or inspect ~/.lima/<instance>/lima.yaml; fix any invalid fields so limayaml.Validate passes.","If the driver is permanently gone, remove stale snapshot state manually (delete the snapshot entries under the instance directory / qcow2 internal snapshots via `qemu-img snapshot -d`) rather than via limactl."],"exampleFix":"// before: instance uses driver \"qemu-ext\" which is uninstalled\n//   limactl snapshot delete inst tag  -> failed to create driver instance\n// after\n//   # reinstall the driver so it is discoverable:\n//   cp lima-driver-qemu-ext ~/.local/libexec/lima/ && chmod +x ~/.local/libexec/lima/lima-driver-qemu-ext\n//   limactl snapshot delete inst tag","handlingStrategy":"try-catch","validationCode":"// Before snapshot operations, check the instance's driver is registered and config is valid:\n// limactl list <inst> && limactl validate ~/.lima/<inst>/lima.yaml\n// Confirm the driver binary exists: ls ~/.local/libexec/lima/lima-driver-* /usr/local/libexec/lima/lima-driver-*","typeGuard":null,"tryCatchPattern":"err := snapshot.Del(ctx, inst, tag)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to create driver instance\") {\n\t\t// surface the wrapped cause: unknown driver / invalid YAML\n\t\treturn fmt.Errorf(\"cannot delete snapshot: driver for instance %q unavailable: %w (reinstall the driver or fix lima.yaml)\", inst.Name, err)\n\t}\n\treturn err\n}","preventionTips":["Don't uninstall an external driver while instances that use it still have snapshots.","Never hand-edit ~/.lima/<inst>/lima.yaml; edit the source template and re-create, or run validation after edits.","Keep the instance's driver binary on the driver path (LIMA_DRIVERS or libexec dir) with the correct lima-driver-<name> naming."],"tags":["snapshot","driver","instance","configuration"],"backgroundTag":"driver-initialization-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}