stablyai/orca · error · Error

Could not resolve the active WSL home directory for Claude l

Error message

Could not resolve the active WSL home directory for Claude login.

What it means

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.

Source

Thrown at src/main/claude-accounts/service.ts:924

  ): ManagedClaudeAuthLocation | null {
    if (process.platform !== 'win32' || target?.runtime !== 'wsl') {
      return null
    }

    const distroArgs = target.wslDistro?.trim() ? ['-d', target.wslDistro.trim()] : []
    const infoOutput = execFileSync(
      'wsl.exe',
      [...distroArgs, '--', 'bash', '-lc', 'printf "%s\\n%s\\n" "$WSL_DISTRO_NAME" "$HOME"'],
      { encoding: 'utf-8', timeout: 5000 }
    )
    const [rawDistro, rawHome] = infoOutput
      .replaceAll(String.fromCharCode(0), '')
      .split(/\r?\n/)
      .map((line) => line.trim())
    const distro = target.wslDistro?.trim() || rawDistro
    const home = rawHome
    if (!distro || !home?.startsWith('/')) {
      throw new Error('Could not resolve the active WSL home directory for Claude login.')
    }

    const wslLinuxAuthPath = `${home.replace(/\/$/, '')}/.local/share/orca/claude-accounts/${accountId}/auth`
    const markerPath = `${wslLinuxAuthPath}/.orca-managed-claude-auth`
    execFileSync(
      'wsl.exe',
      [
        '-d',
        distro,
        '--',
        'bash',
        '-lc',
        `mkdir -p ${shellQuote(wslLinuxAuthPath)} && printf '%s\\n' ${shellQuote(accountId)} > ${shellQuote(markerPath)}`
      ],
      { encoding: 'utf-8', timeout: 5000 }
    )

    const managedAuthPath = toWindowsWslPath(wslLinuxAuthPath, distro)

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Run 'wsl -l -v' in a Windows terminal and confirm a distro is listed as default; set one with 'wsl --set-default <Distro>'.
  2. 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.
  3. Check the target.wslDistro value passed by the caller matches an installed distro name exactly (case-sensitive on some builds).
  4. Ensure the WSL2 service is running: 'wsl --status' and restart it if 'bash -lc' produces no output.

Example fix

// before: no distro set, HOME resolves empty
// after: explicitly pass the distro and verify it exists
const distros = execFileSync('wsl.exe', ['-l', '-q'], { encoding: 'utf-8' })
  .replaceAll(String.fromCharCode(0), '').trim().split(/\r?\n/)
if (!distros.includes(target.wslDistro)) {
  throw new Error(`WSL distro '${target.wslDistro}' not found. Available: ${distros.join(', ')}`)
}
Defensive patterns

Strategy: validation

Validate before calling

// Before calling tryCreateWslManagedAuthDir, verify WSL is functional
import { execFileSync } from 'node:child_process'

function canResolveWslHome(wslDistro?: string): boolean {
  try {
    const distroArgs = wslDistro?.trim() ? ['-d', wslDistro.trim()] : []
    const out = execFileSync('wsl.exe',
      [...distroArgs, '--', 'bash', '-lc', 'printf "%s\\n%s\\n" "$WSL_DISTRO_NAME" "$HOME"'],
      { encoding: 'utf-8', timeout: 5000 }
    )
    const [distro, home] = out.replaceAll(String.fromCharCode(0), '').split(/\r?\n/).map(l => l.trim())
    return !!distro && !!home?.startsWith('/')
  } catch {
    return false
  }
}

Try / catch

try {
  // createManagedAuthDir with WSL target
} catch (error) {
  if (error instanceof Error && error.message.includes('Could not resolve the active WSL home')) {
    // Surface actionable guidance: WSL not ready, distro missing, or HOME unset
    showUserGuidance('WSL is not ready. Run "wsl -l -v" to verify your distro, then retry.')
  } else {
    throw error
  }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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).

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/b52532743b3f2a33. Report an issue: GitHub.