mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
fix(wsl): write the Claude account pointer through stdin, not an empty argument (#41869)
wsl.exe --exec refuses an empty argument with Wsl/Service/E_INVALIDARG. When a managed WSL Claude account exists but the distro is on System default, the pointer content is the empty string, so every Claude launch in that distro failed before its terminal spawned. This hits both Windows-driven WSL panes and WSL hosts, whose account env is prepared by the desktop. Fixes #41160
This commit is contained in:
@@ -45,8 +45,13 @@ vi.mock('../../../wsl/execution/wsl-runner', () => ({
|
||||
if (guest.failure) {
|
||||
return { ...guest.failure, stderr: '', timedOut: false }
|
||||
}
|
||||
// Real wsl.exe --exec refuses an empty argument before the guest runs.
|
||||
if (spec.args?.some((arg) => arg === '')) {
|
||||
return { code: 1, stdout: '', stderr: 'Wsl/Service/E_INVALIDARG', timedOut: false }
|
||||
}
|
||||
const result = spawnSync('/bin/sh', ['-c', spec.script ?? '', 'sh', ...(spec.args ?? [])], {
|
||||
encoding: 'utf8'
|
||||
encoding: 'utf8',
|
||||
input: spec.input
|
||||
})
|
||||
return { code: result.status, stdout: result.stdout, stderr: result.stderr, timedOut: false }
|
||||
}
|
||||
@@ -141,6 +146,17 @@ describe.skipIf(!posixHost)('ClaudeWslProfileRouter', () => {
|
||||
expect(readFileSync(f.pointer, 'utf8')).toBe(homeB)
|
||||
})
|
||||
|
||||
it('launches on System default while a managed WSL account still exists', async () => {
|
||||
const f = fixture()
|
||||
mkdirSync(join(f.pointer, '..'), { recursive: true })
|
||||
writeFileSync(f.pointer, f.profileHome)
|
||||
f.wsl.Ubuntu = null
|
||||
await expect(f.router.prepareLaunch('Ubuntu')).resolves.toMatchObject({
|
||||
provenance: 'wsl:Ubuntu:system'
|
||||
})
|
||||
expect(readFileSync(f.pointer, 'utf8')).toBe('')
|
||||
})
|
||||
|
||||
it("runs an account with no login of its own on the guest's ~/.claude while that is signed in to it", async () => {
|
||||
const f = fixture()
|
||||
mkdirSync(f.profileHome, { recursive: true })
|
||||
|
||||
@@ -262,10 +262,11 @@ async function writePointer(distro: string, pointer: string, home: string): Prom
|
||||
if (current === home) {
|
||||
return
|
||||
}
|
||||
// wsl.exe --exec rejects an empty argument (E_INVALIDARG), and System default writes ''; pass content on stdin.
|
||||
await runGuest(distro, {
|
||||
script:
|
||||
'umask 077; mkdir -p -- "${1%/*}" && printf %s "$2" > "$1.tmp" && mv -f -- "$1.tmp" "$1"',
|
||||
args: [pointer, home],
|
||||
script: 'umask 077; mkdir -p -- "${1%/*}" && cat > "$1.tmp" && mv -f -- "$1.tmp" "$1"',
|
||||
args: [pointer],
|
||||
input: home,
|
||||
loginPath: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user