[BUG] /background fails with "EUNKNOWN: unknown error, uv_spawn" — daemon autostart hard-codes the Windows PowerShell 5.1 absolute path, which enterprise Group Policy blocks
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Any entry point that needs the background supervisor daemon fails when no daemon is running:
> claude --bg "do something"
Starting background service…
Couldn't start the session — EUNKNOWN: unknown error, uv_spawn
Same for the /background (/bg) slash command. Regular interactive sessions, the Bash/PowerShell tools, and subagents all work fine.
Root cause (verified)
The Windows daemon autostart spawns the daemon via WMI (Win32_Process.Create) so it survives terminal close, and it invokes that through a hard-coded absolute path to Windows PowerShell 5.1:
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive -EncodedCommand <base64>
On machines where Group Policy blocks that binary (a common enterprise hardening setup: WPSh 5.1 disabled in favor of PowerShell 7), CreateProcess fails with Win32 error 1260 (ERROR_ACCESS_DISABLED_BY_POLICY). libuv has no errno mapping for 1260, so the user sees the opaque EUNKNOWN: unknown error, uv_spawn.
Verification performed:
- A minimal CreateProcessW test against
powershell.exe(5.1) fails with Win32 error 1260 under every flag combination (baseline,DETACHED_PROCESS,CREATE_NO_WINDOW, etc.). - The same test against
claude.exesucceeds with every combination, includingDETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP— so detached spawning itself is not restricted on this machine. - The direct-spawn fallback after the WMI attempt does not appear to engage: after the failure,
claude daemon statusreportsnot runninganddaemon.loghas noorigin=transientstart entry.
Workaround
Manually starting the supervisor first makes everything work, since the blocked autostart step is skipped:
claude daemon run # in a separate terminal (or spawned hidden)
claude --bg "..." # now succeeds; /background works too
Background sessions then spawn and run normally under the daemon.
Suggested fixes
- Prefer
pwsh.exe(PowerShell 7) for the WMI spawn helper when available, falling back to Windows PowerShell 5.1 — mirrors what the PowerShell tool already does. - When CreateProcess fails with 1260, surface a clear message ("blocked by Group Policy") and hint at the
claude daemon runworkaround instead ofEUNKNOWN: unknown error, uv_spawn. - Investigate why the direct-spawn fallback after a failed WMI attempt doesn't leave a transient daemon running in this scenario.
What Should Happen?
claude --bg / /background should start the background supervisor daemon and detach the session, as it does on machines without this Group Policy restriction.
Ideally the daemon autostart should not depend on the Windows PowerShell 5.1 binary when pwsh.exe (PowerShell 7) is available — or at minimum, the error should clearly say the spawn was blocked by Group Policy instead of EUNKNOWN: unknown error, uv_spawn.
Error Messages/Logs
Steps to Reproduce
- Use a Windows 11 machine where Group Policy blocks execution of Windows PowerShell 5.1 (
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe; CreateProcess fails with Win32 error 1260) while PowerShell 7 (pwsh.exe) is allowed. - Make sure no supervisor daemon is running:
claude daemon stop --any(status should saynot running). - Run
claude --bg "test"from any project directory (or use/backgroundinside an interactive session). - Observe:
````
Starting background service…
Couldn't start the session — EUNKNOWN: unknown error, uv_spawn
claude daemon statusstill reportsnot running, anddaemon.loghas noorigin=transiententry.- Now run
claude daemon runin a separate terminal and repeat step 3 — it succeeds.
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.209 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Windows 11 Enterprise (10.0.26200), Claude Code native install. PowerShell 7 is present and allowed; only Windows PowerShell 5.1 is blocked by policy.
Possibly related but distinct: #21843 / #25558 (CLAUDE_CODE_SHELL ignored on Windows) cover shell selection for the Bash tool, not this daemon autostart path.