{"record":{"id":"26c3721378219623","repo":"stablyai/orca","slug":"could-not-resolve-the-active-wsl-home-directory-fo-26c372","errorCode":null,"errorMessage":"Could not resolve the active WSL home directory for Codex login.","messagePattern":"Could not resolve the active WSL home directory for Codex login\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/codex-accounts/service.ts","lineNumber":1173,"sourceCode":"  ): ManagedHomeLocation | null {\n    if (process.platform !== 'win32' || target?.runtime !== 'wsl') {\n      return null\n    }\n\n    const distroArgs = target.wslDistro?.trim() ? ['-d', target.wslDistro.trim()] : []\n    const infoOutput = execFileSync(\n      'wsl.exe',\n      [...distroArgs, '--', 'bash', '-lc', 'printf \"%s\\\\n%s\\\\n\" \"$WSL_DISTRO_NAME\" \"$HOME\"'],\n      { encoding: 'utf-8', timeout: 5000 }\n    )\n    const [rawDistro, rawHome] = infoOutput\n      .replaceAll(String.fromCharCode(0), '')\n      .split(/\\r?\\n/)\n      .map((line) => line.trim())\n    const distro = target.wslDistro?.trim() || rawDistro\n    const home = rawHome\n    if (!distro || !home?.startsWith('/')) {\n      throw new Error('Could not resolve the active WSL home directory for Codex login.')\n    }\n\n    const wslLinuxHomePath = `${home.replace(/\\/$/, '')}/.local/share/orca/codex-accounts/${accountId}/home`\n    const markerPath = `${wslLinuxHomePath}/.orca-managed-home`\n    execFileSync(\n      'wsl.exe',\n      [\n        '-d',\n        distro,\n        '--',\n        'bash',\n        '-lc',\n        `mkdir -p ${shellQuote(wslLinuxHomePath)} && printf '%s\\\\n' ${shellQuote(accountId)} > ${shellQuote(markerPath)}`\n      ],\n      { encoding: 'utf-8', timeout: 5000 }\n    )\n\n    const managedHomePath = toWindowsWslPath(wslLinuxHomePath, distro)","sourceCodeStart":1155,"sourceCodeEnd":1191,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/codex-accounts/service.ts#L1155-L1191","documentation":"Thrown by tryCreateWslManagedHome when probing the active WSL distro's $HOME via wsl.exe failed to yield a usable distro name and a Linux home path starting with '/'. Orca builds the managed WSL Codex home under $HOME/.local/share/orca/codex-accounts/<id>/home, so both values are required before it creates anything.","triggerScenarios":"Adding a Codex account with target.runtime 'wsl' on Windows; wsl.exe printed output that, after null-stripping and trimming, has an empty distro or a HOME that does not start with '/' (e.g. wsl.exe unavailable, returned an error string, or HOME unset in the distro profile).","commonSituations":"WSL not installed / no distro registered (wsl.exe errors to stdout), the requested --wslDistro does not exist, the distro's shell profile clears/unsets HOME, or a non-standard login shell that suppresses the printf output.","solutions":["Confirm WSL is installed and a distro is registered: run `wsl -l -v` and ensure the target distro is default/listed.","Verify the distro's `bash -lc 'echo $HOME'` prints an absolute Linux path; fix the shell profile if HOME is unset.","Pass the explicit distro via target.wslDistro so Orca does not rely on the default distro resolution.","If WSL is unavailable, add the account under the host runtime instead."],"exampleFix":"# before: WSL distro has no usable HOME\nwsl.exe -d BrokenDistro -- bash -lc 'echo $HOME'   # empty / unset\nservice.addAccount({ runtime: 'wsl', wslDistro: 'BrokenDistro' })  # throws [914]\n\n# after: fix the distro profile so HOME resolves, or pick a healthy distro\necho 'export HOME=$(/usr/bin/getent passwd $(id -un) | cut -d: -f6)' >> ~/.bashrc\nservice.addAccount({ runtime: 'wsl', wslDistro: 'Ubuntu' })","handlingStrategy":"fallback","validationCode":"// Probe WSL HOME/distro before attempting a WSL account add.\nimport { execFileSync } from 'node:child_process'\nfunction probeWslHome(distro?: string): { distro: string; home: string } | null {\n  try {\n    const out = execFileSync('wsl.exe', [...(distro ? ['-d', distro] : []), '--', 'bash', '-lc',\n      'printf \"%s\\\\n%s\" \"$WSL_DISTRO_NAME\" \"$HOME\"'], { encoding: 'utf-8', timeout: 5000 })\n    const [d, h] = out.replaceAll(String.fromCharCode(0), '').split(/\\r?\\n/).map(s => s.trim())\n    return d && h?.startsWith('/') ? { distro: d, home: h } : null\n  } catch { return null }\n}\nif (!probeWslHome(target.wslDistro)) { /* fall back to host or surface WSL setup error */ }","typeGuard":null,"tryCatchPattern":"try {\n  await service.addAccount({ runtime: 'wsl', wslDistro })\n} catch (error) {\n  if (error instanceof Error && error.message.includes('WSL home directory')) {\n    // fall back to host runtime or guide WSL setup\n    await service.addAccount()\n  } else throw error\n}","preventionTips":["Ensure a healthy WSL distro with a resolving $HOME is registered before adding WSL accounts.","Pass target.wslDistro explicitly rather than relying on the default distro."],"tags":["codex-accounts","wsl","windows","environment","add-account"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}