{"record":{"id":"fd5f1e311b4048d6","repo":"lima-vm/lima","slug":"failed-to-run-wsl-list-verbose-err-w-out","errorCode":null,"errorMessage":"failed to run `wsl --list --verbose`, err: %w (out=%#q)","messagePattern":"failed to run `wsl --list --verbose`, err: %w \\(out=%#q\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/wsl2/vm_windows.go","lineNumber":216,"sourceCode":"// Distributions can also be installed by visiting the Microsoft Store:\n// https://aka.ms/wslstore\n// Error code: Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND\n//\n// (3) Expected output when no distros are installed, and WSL2 has no kernel installed:\n//\n// PS > wsl --list --verbose\n// Windows Subsystem for Linux has no installed distributions.\n// Distributions can be installed by visiting the Microsoft Store:\n// https://aka.ms/wslstore\nfunc getWslStatus(ctx context.Context, instName string) (string, error) {\n\tdistroName := \"lima-\" + instName\n\tout, err := executil.RunUTF16leCommand([]string{\n\t\t\"wsl.exe\",\n\t\t\"--list\",\n\t\t\"--verbose\",\n\t}, executil.WithContext(ctx))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to run `wsl --list --verbose`, err: %w (out=%#q)\", err, out)\n\t}\n\n\tif out == \"\" {\n\t\treturn limatype.StatusBroken, fmt.Errorf(\"failed to read instance state for instance %#q, try running `wsl --list --verbose` to debug, err: %w\", instName, err)\n\t}\n\n\t// Check for edge cases first\n\tif strings.Contains(out, \"Windows Subsystem for Linux has no installed distributions.\") {\n\t\tif strings.Contains(out, \"Wsl/WSL_E_DEFAULT_DISTRO_NOT_FOUND\") {\n\t\t\treturn limatype.StatusBroken, fmt.Errorf(\n\t\t\t\t\"failed to read instance state for instance %#q because no distro is installed,\"+\n\t\t\t\t\t\"try running `wsl --install -d Ubuntu` and then re-running Lima\", instName)\n\t\t}\n\t\treturn limatype.StatusBroken, fmt.Errorf(\n\t\t\t\"failed to read instance state for instance %#q because there is no WSL kernel installed,\"+\n\t\t\t\t\"this usually happens when WSL was installed for another user, but never for your user.\"+\n\t\t\t\t\"Try running `wsl --install -d Ubuntu` and `wsl --update`, and then re-running Lima\", instName)\n\t}","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/wsl2/vm_windows.go#L198-L234","documentation":"To determine instance state, the driver runs `wsl.exe --list --verbose` (UTF-16le output) and parses it. Any failure of that command is wrapped with the raw output so the user can debug WSL directly; no state string is produced.","triggerScenarios":"getWslStatus (via InspectStatus, Delete, Start) invokes `wsl.exe --list --verbose` and it exits non-zero — WSL not installed, wsl.exe path issues, or WSL service errors.","commonSituations":"WSL feature not enabled on Windows, wsl.exe outdated or corrupted, running in a context where wsl.exe is unavailable, WSL first-run not completed.","solutions":["Run `wsl --list --verbose` manually in PowerShell to reproduce and see the real error","Install/enable WSL: `wsl --install` and reboot","Update WSL with `wsl --update`","Retry the limactl command after WSL responds correctly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Preflight: confirm wsl.exe works before Lima operations\nexecSync('wsl.exe --list --verbose', { stdio: 'inherit' });","typeGuard":"function isWslListError(e) { return String(e).includes('--list --verbose'); }","tryCatchPattern":"try {\n  await limactlStart(inst);\n} catch (e) {\n  if (String(e).includes('--list --verbose')) {\n    throw new Error('WSL CLI unavailable; run `wsl --install` / `wsl --update` first. Original: ' + e.message);\n  } else throw e;\n}","preventionTips":["Verify `wsl --list --verbose` runs before installing Lima instances","Complete `wsl --install` and reboot before first `limactl start`","Keep WSL from the Microsoft Store updated (`wsl --update`)"],"tags":["wsl2","state-detection","wsl-cli"],"backgroundTag":"wsl-command-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}