{"record":{"id":"b52532743b3f2a33","repo":"stablyai/orca","slug":"could-not-resolve-the-active-wsl-home-directory-fo","errorCode":null,"errorMessage":"Could not resolve the active WSL home directory for Claude login.","messagePattern":"Could not resolve the active WSL home directory for Claude login\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/claude-accounts/service.ts","lineNumber":924,"sourceCode":"  ): ManagedClaudeAuthLocation | 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 Claude login.')\n    }\n\n    const wslLinuxAuthPath = `${home.replace(/\\/$/, '')}/.local/share/orca/claude-accounts/${accountId}/auth`\n    const markerPath = `${wslLinuxAuthPath}/.orca-managed-claude-auth`\n    execFileSync(\n      'wsl.exe',\n      [\n        '-d',\n        distro,\n        '--',\n        'bash',\n        '-lc',\n        `mkdir -p ${shellQuote(wslLinuxAuthPath)} && printf '%s\\\\n' ${shellQuote(accountId)} > ${shellQuote(markerPath)}`\n      ],\n      { encoding: 'utf-8', timeout: 5000 }\n    )\n\n    const managedAuthPath = toWindowsWslPath(wslLinuxAuthPath, distro)","sourceCodeStart":906,"sourceCodeEnd":942,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/claude-accounts/service.ts#L906-L942","documentation":"Thrown by tryCreateWslManagedAuthDir when Orca cannot determine the active WSL distro name or the Linux $HOME path. The code shells out to wsl.exe to print $WSL_DISTRO_NAME and $HOME, then requires a non-empty distro and a HOME that starts with '/'. If either is missing or malformed, the managed WSL auth directory cannot be safely created.","triggerScenarios":"Calling Claude account add/login with target.runtime === 'wsl' on Windows. Specifically when execFileSync('wsl.exe', ...) returns output where rawDistro is empty, rawHome is empty, or rawHome does not start with '/'. Also when wsl.exe itself fails or times out (5000ms).","commonSituations":"WSL is installed but no default distro is set (wsl.exe launches the store page instead of printing env). The user's .bashrc/.profile errors out so 'bash -lc' produces no clean output. A custom WSL distro with HOME unset or set to a Windows-style path. WSL2 service not running (wsl.exe hangs then times out).","solutions":["Run 'wsl -l -v' in a Windows terminal and confirm a distro is listed as default; set one with 'wsl --set-default <Distro>'.","Run 'wsl -- bash -lc \"printf %s\\\\n%s\\\\n \\\"$WSL_DISTRO_NAME\\\" \\\"$HOME\\\"\"' manually and confirm two lines print with the second being an absolute Linux path.","Check the target.wslDistro value passed by the caller matches an installed distro name exactly (case-sensitive on some builds).","Ensure the WSL2 service is running: 'wsl --status' and restart it if 'bash -lc' produces no output."],"exampleFix":"// before: no distro set, HOME resolves empty\n// after: explicitly pass the distro and verify it exists\nconst distros = execFileSync('wsl.exe', ['-l', '-q'], { encoding: 'utf-8' })\n  .replaceAll(String.fromCharCode(0), '').trim().split(/\\r?\\n/)\nif (!distros.includes(target.wslDistro)) {\n  throw new Error(`WSL distro '${target.wslDistro}' not found. Available: ${distros.join(', ')}`)\n}","handlingStrategy":"validation","validationCode":"// Before calling tryCreateWslManagedAuthDir, verify WSL is functional\nimport { execFileSync } from 'node:child_process'\n\nfunction canResolveWslHome(wslDistro?: string): boolean {\n  try {\n    const distroArgs = wslDistro?.trim() ? ['-d', wslDistro.trim()] : []\n    const out = execFileSync('wsl.exe',\n      [...distroArgs, '--', 'bash', '-lc', 'printf \"%s\\\\n%s\\\\n\" \"$WSL_DISTRO_NAME\" \"$HOME\"'],\n      { encoding: 'utf-8', timeout: 5000 }\n    )\n    const [distro, home] = out.replaceAll(String.fromCharCode(0), '').split(/\\r?\\n/).map(l => l.trim())\n    return !!distro && !!home?.startsWith('/')\n  } catch {\n    return false\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  // createManagedAuthDir with WSL target\n} catch (error) {\n  if (error instanceof Error && error.message.includes('Could not resolve the active WSL home')) {\n    // Surface actionable guidance: WSL not ready, distro missing, or HOME unset\n    showUserGuidance('WSL is not ready. Run \"wsl -l -v\" to verify your distro, then retry.')\n  } else {\n    throw error\n  }\n}","preventionTips":["Verify a default WSL distro is set before triggering WSL-based Claude login.","Test 'wsl -- bash -lc \"echo $HOME\"' returns a valid path in CI/onboarding.","Pre-warm WSL by running a trivial command before account operations."],"tags":["wsl","windows","claude-accounts","shell-execution","environment"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}