{"record":{"id":"b451e4289d75d1fc","repo":"lima-vm/lima","slug":"failed-to-run-wslpath-command-w","errorCode":null,"errorMessage":"failed to run wslpath command: %w","messagePattern":"failed to run wslpath command: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/wsl2/vm_windows.go","lineNumber":113,"sourceCode":"\t\treturn err\n\t}\n\t// path should be quoted and use \\\\ as separator\n\tbootFileWSLPath := strconv.Quote(limaBootFileWinPath)\n\tlimaBootFilePathOnLinuxB, err := exec.CommandContext(\n\t\tctx,\n\t\t\"wsl.exe\",\n\t\t\"-d\",\n\t\tdistroName,\n\t\t\"bash\",\n\t\t\"-c\",\n\t\tfmt.Sprintf(\"wslpath -u %s\", bootFileWSLPath),\n\t\tbootFileWSLPath,\n\t).Output()\n\tif err != nil {\n\t\tos.RemoveAll(limaBootFileWinPath)\n\t\t// this can return an error with an exit code, which causes it not to be logged\n\t\t// because main.handleExitCoder() traps it, so wrap the error\n\t\treturn fmt.Errorf(\"failed to run wslpath command: %w\", err)\n\t}\n\tlimaBootFileLinuxPath := strings.TrimSpace(string(limaBootFilePathOnLinuxB))\n\tgo func() {\n\t\tcmd := exec.CommandContext(\n\t\t\tctx,\n\t\t\t\"wsl.exe\",\n\t\t\t\"-d\",\n\t\t\tdistroName,\n\t\t\t\"bash\",\n\t\t\t\"-c\",\n\t\t\tlimaBootFileLinuxPath,\n\t\t)\n\t\tout, err := cmd.CombinedOutput()\n\t\tos.RemoveAll(limaBootFileWinPath)\n\t\tlogrus.Debugf(\"%v: %#q\", cmd.Args, string(out))\n\t\tif err != nil {\n\t\t\terrCh <- fmt.Errorf(\n\t\t\t\t\"error running wslCommand that executes boot.sh (%v): %w, \"+","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/wsl2/vm_windows.go#L95-L131","documentation":"provisionVM runs a wslpath command to convert the Windows temp boot-script path into its Linux-side path inside the WSL distro. On failure it removes the temp file and returns this wrapped error (explicitly wrapped so handleExitCoder doesn't swallow exit-code errors). It means the boot script path could not be translated, so provisioning cannot proceed.","triggerScenarios":"Start() -> provisionVM when the wslpath command exits non-zero: the WSL distro is not running, wsl.exe invocation fails, or the distro lacks /usr/bin/wslpath (non-standard/failed init).","commonSituations":"Distro failed to fully boot so wslpath (part of WSL's init/interop) is unavailable; WSL interop disabled (appendWindowsPath/interop settings); path with characters wslpath mishandles; WSL service wedged.","solutions":["Ensure the distro is running and healthy: `wsl.exe --distribution <name> -- true`; restart if not","Check WSL interop is enabled in .wslconfig (interop enabled) so Windows->Linux command execution works","Read the wrapped err for the exit code; run the wslpath conversion manually to reproduce","Recreate the distro (`limactl delete` + `limactl start`) if the guest init is broken","Update WSL (`wsl.exe --update`) — interop/wslpath issues are fixed in newer releases"],"exampleFix":"// before (silent exit-code swallow in callers)\n// after (driver wraps it): inspect and retry\nif err := driver.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"wslpath\") {\n        exec.Command(\"wsl.exe\", \"--shutdown\").Run() // reset WSL then retry\n    }\n}","handlingStrategy":"retry","validationCode":"// verify the distro is bootable and interop works before provisioning\nif err := exec.Command(\"wsl.exe\", \"-d\", distroName, \"--\", \"/usr/bin/wslpath\", \"C:\\\\\").Run(); err != nil {\n    return errors.New(\"wsl interop/wslpath unavailable; check distro health and .wslconfig interop settings\")\n}","typeGuard":null,"tryCatchPattern":"if err := driver.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"wslpath\") {\n        exec.Command(\"wsl.exe\", \"--shutdown\").Run()\n        time.Sleep(2 * time.Second)\n        return driver.Start(ctx) // one reset-and-retry\n    }\n    return err\n}","preventionTips":["Keep WSL interop enabled (interop.enabled=true in .wslconfig)","Use standard WSL distro images that ship wslpath/init","Update WSL regularly (`wsl --update`)","Avoid paths with exotic characters in instance directories"],"tags":["wsl2","windows","wslpath","provisioning"],"backgroundTag":"wsl-command-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}