From 4560435dd9c98076ac1613e50febdffa5667f475 Mon Sep 17 00:00:00 2001 From: LukeParkerDev <10430890+Hona@users.noreply.github.com> Date: Fri, 17 Apr 2026 14:52:10 +1000 Subject: [PATCH] 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. --- packages/desktop-electron/src/main/wsl.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/desktop-electron/src/main/wsl.ts b/packages/desktop-electron/src/main/wsl.ts index 6f5c2bca17..7f441ceae9 100644 --- a/packages/desktop-electron/src/main/wsl.ts +++ b/packages/desktop-electron/src/main/wsl.ts @@ -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 = {}) {