{"record":{"id":"894e209dad9ef12b","repo":"lima-vm/lima","slug":"error-running-wslcommand-that-executes-boot-sh-v","errorCode":null,"errorMessage":"error running wslCommand that executes boot.sh (%v): %w, check /var/log/lima-init.log for more details (out=%#q)","messagePattern":"error running wslCommand that executes boot\\.sh \\((.+?)\\): %w, check /var/log/lima-init\\.log for more details \\(out=%#q\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/wsl2/vm_windows.go","lineNumber":130,"sourceCode":"\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, \"+\n\t\t\t\t\t\"check /var/log/lima-init.log for more details (out=%#q)\", cmd.Args, err, string(out))\n\t\t}\n\n\t\t<-ctx.Done()\n\t\tlogrus.Info(\"Context closed, stopping vm\")\n\t\tif status, err := getWslStatus(ctx, instanceName); err == nil &&\n\t\t\tstatus == limatype.StatusRunning {\n\t\t\t_ = stopVM(ctx, distroName)\n\t\t}\n\t}()\n\n\treturn err\n}\n\n// keepAlive runs a background process which in order to keep the WSL2 VM running in the background after launch.\nfunc keepAlive(ctx context.Context, distroName string, errCh chan<- error) {\n\tkeepAliveCmd := exec.CommandContext(","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/wsl2/vm_windows.go#L112-L148","documentation":"Lima's WSL2 driver runs the instance's boot.sh provisioning script inside the WSL distro via wslCommand and captures its combined output. If the command exits non-zero, Lima wraps the original error together with the command arguments and captured output, because boot.sh failure means guest provisioning did not complete.","triggerScenarios":"The wsl.exe invocation executing lima-boot-file (boot.sh) returns a non-zero exit status during instance start; cmd.CombinedOutput() populates err. Provisioning commands inside boot.sh (package installs, systemctl, user setup) fail inside the guest.","commonSituations":"A provisioning script step fails due to no network in the guest, a bad apt/yum mirror, invalid provisioning YAML converted into boot.sh, or the distro not being fully initialized when boot.sh runs. The real cause is visible in /var/log/lima-init.log inside the distro.","solutions":["Read /var/log/lima-init.log inside the distro (wsl -d <distroName> cat /var/log/lima-init.log) to find the failing provisioning step","Inspect the out= portion of this error for stderr from boot.sh","Fix or remove the failing provisioning steps in the instance's Lima YAML (provision section) and recreate the instance","Ensure the guest has network/DNS access and the distro finished first-boot setup before provisioning","Rerun limactl start after fixing; delete the broken instance with limactl delete if provisioning is half-applied"],"exampleFix":"// before\nprovision:\n  - mode: system\n    script: apt-get install -y mypkg   # fails if apt index is stale\n// after\nprovision:\n  - mode: system\n    script: apt-get update && apt-get install -y mypkg","handlingStrategy":"try-catch","validationCode":"// Verify provisioning script is syntactically valid before start\nconst { execFileSync } = require('child_process');\nexecFileSync('bash', ['-n', 'boot.sh'], { stdio: 'inherit' }); // syntax check","typeGuard":"function hasBootOutput(r) { return r && typeof r.out === 'string'; }","tryCatchPattern":"try {\n  await limactlStart(inst);\n} catch (e) {\n  if (String(e).includes('error running wslCommand that executes boot.sh')) {\n    const log = execFileSync('wsl', ['-d', distro, 'cat', '/var/log/lima-init.log']).toString();\n    console.error('Provisioning failed; lima-init.log tail:', log.slice(-2000));\n  } else throw e;\n}","preventionTips":["Syntax-check provisioning scripts with bash -n before embedding them in lima.yaml","Keep provisioning steps idempotent so a retry after partial failure succeeds","Test provisioning scripts in a plain WSL distro before adding them to Lima config","Ensure guest network/DNS works; add apt-get update before installs"],"tags":["wsl2","provisioning","guest-startup"],"backgroundTag":"guest-provisioning-script-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}