fix(desktop-wsl): spawn WSL commands as root to bypass first-run setup

A freshly installed Ubuntu-24.04 distro prompts interactively for a new UNIX user on its first invocation; with piped stdio that prompt blocks forever and the sidecar never starts. Adding --user root to wslArgs sidesteps the whole first-run flow for every wsl.exe we spawn (sidecar, resolveWslOpencode, probes). opencode inside WSL only needs an HTTP listener so running as root is fine.
This commit is contained in:
LukeParkerDev
2026-04-17 14:52:10 +10:00
parent 3349fb95ca
commit 4560435dd9

View File

@@ -18,9 +18,17 @@ type RunWslOptions = {
signal?: AbortSignal
}
// `--user root` bypasses the distro's default-user requirement. A freshly
// installed WSL distro (Ubuntu-24.04 in particular) prompts interactively
// for a username/password on its first invocation; when spawned with
// piped stdio that prompt blocks forever or silently reads garbage,
// leaving the sidecar hanging and the server unhealthy. Running as root
// sidesteps the entire first-run setup flow — opencode only needs an
// HTTP listener in the distro, not a per-user environment, so root is
// a safe default for the sidecar process.
export function wslArgs(args: string[], distro?: string | null) {
if (distro) return ["-d", distro, "--", ...args]
return ["--", ...args]
if (distro) return ["-d", distro, "--user", "root", "--", ...args]
return ["--user", "root", "--", ...args]
}
export function runWsl(args: string[], opts: RunWslOptions = {}) {