claude-code - 💡(How to fix) Fix [BUG] Windows: PowerShell tool returns Exit 1 silently — pwsh works fine outside CC[Bug] Windows: PowerShell tool returns Exit 1 silently — pwsh works fine outside CC [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#60664Fetched 2026-05-20 03:52:41
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×1

On Claude Code Desktop 2.1.142 (Windows 11), every invocation of the native PowerShell tool returns Exit code 1 with no output and no error message, even for trivial commands like "hello" or Write-Output "test".

The bug is persistent across:

  • Closing and reopening Claude Code Desktop
  • Full Windows reboot

The Bash tool works normally throughout, and PowerShell itself is fully functional when invoked from the Bash tool (pwsh -Command "..." or powershell -Command "...").

Error Message

On Claude Code Desktop 2.1.142 (Windows 11), every invocation of the native PowerShell tool returns Exit code 1 with no output and no error message, even for trivial commands like "hello" or Write-Output "test". Exit code 1, no output at all. The error is silent — nothing surfaces to the user beyond the bare exit code.

Error Messages/Logs

Root Cause

On Claude Code Desktop 2.1.142 (Windows 11), every invocation of the native PowerShell tool returns Exit code 1 with no output and no error message, even for trivial commands like "hello" or Write-Output "test".

The bug is persistent across:

  • Closing and reopening Claude Code Desktop
  • Full Windows reboot

The Bash tool works normally throughout, and PowerShell itself is fully functional when invoked from the Bash tool (pwsh -Command "..." or powershell -Command "...").

Fix Action

Fix / Workaround

Workaround (validated) Invoking PowerShell through the Bash tool works perfectly:

Impact Low/medium. The Bash → pwsh workaround is trivial. But:

Users not aware of the workaround will think PowerShell is broken on their system Verbose syntax overhead (pwsh -Command "..." instead of native PowerShell tool) Project-level settings.json permissions for PowerShell(...) patterns become useless until the bug is fixed

Code Example

"hello"

### What Should Happen?

Result: Exit code 1, no stdout, no stderr
Expected behavior
Output of the command (e.g. hello).

Actual behavior
Exit code 1, no output at all. The error is silent — nothing surfaces to the user beyond the bare exit code.



### Error Messages/Logs
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Description

On Claude Code Desktop 2.1.142 (Windows 11), every invocation of the native PowerShell tool returns Exit code 1 with no output and no error message, even for trivial commands like "hello" or Write-Output "test".

The bug is persistent across:

  • Closing and reopening Claude Code Desktop
  • Full Windows reboot

The Bash tool works normally throughout, and PowerShell itself is fully functional when invoked from the Bash tool (pwsh -Command "..." or powershell -Command "...").

Environment

  • OS: Windows 11 (build 26100.8457)
  • Claude Code Desktop version: 2.1.142 (auto-updated, latest available)
  • CLI npm version: 2.1.138 (@anthropic-ai/claude-code published 2.1.144)
  • pwsh version: 7.6.1 (installed via Microsoft Store — Microsoft.PowerShell_7.6.1.0_x64__8wekyb3d8bbwe)
  • Windows PowerShell version: 5.1.26100.8457
  • Session entrypoint (from ~/.claude/sessions/<pid>.json): claude-desktop

Steps to reproduce

  1. Open Claude Code Desktop on Windows 11
  2. Invoke the PowerShell tool with any command, e.g.:
    "hello"

What Should Happen?

Result: Exit code 1, no stdout, no stderr Expected behavior Output of the command (e.g. hello).

Actual behavior Exit code 1, no output at all. The error is silent — nothing surfaces to the user beyond the bare exit code.

Error Messages/Logs

Steps to Reproduce

Workaround (validated) Invoking PowerShell through the Bash tool works perfectly:

pwsh -Command "Write-Output 'test'" # → test pwsh -NonInteractive -NoProfile -Command "..." # → OK powershell -Command "Get-Service ssh-agent" # → OK

So the issue is specifically with how claude.exe invokes pwsh internally, not with PowerShell itself.

Investigation done pwsh.exe and powershell.exe are both accessible and functional from Bash tool All PowerShell $PROFILE.* paths return Test-Path = False (no profiles installed, not the cause) PATH includes both /c/WINDOWS/System32/WindowsPowerShell/v1.0 and /c/Users/<user>/AppData/Local/Microsoft/WindowsApps ~/.claude/shell-snapshots/ contains only snapshot-bash-.sh files — no PowerShell snapshot is ever generated, even after many tool invocations The cache directory ~/AppData/Local/Microsoft/PowerShell/7.6.1/ contains a StartupProfileData-NonInteractive file that is regenerated normally on direct pwsh invocations from Bash winget upgrade Microsoft.PowerShell reports "no newer version available" pwsh works in all modes when invoked from Bash: -NoProfile, -NonInteractive, -NoProfile -NonInteractive, with .exe or via execution alias Hypothesis Claude Code Desktop on Windows appears to fail at creating its shell-snapshot for PowerShell at session initialization. The absence of any snapshot-pwsh-.ps1 (or similar) in ~/.claude/shell-snapshots/ suggests the snapshot generation crashes silently, and all subsequent PowerShell tool invocations inherit that broken state.

Impact Low/medium. The Bash → pwsh workaround is trivial. But:

Users not aware of the workaround will think PowerShell is broken on their system Verbose syntax overhead (pwsh -Command "..." instead of native PowerShell tool) Project-level settings.json permissions for PowerShell(...) patterns become useless until the bug is fixed

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

CC Desktop = 2.1.142

Claude Code Version

2.1.138

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Windows: PowerShell tool returns Exit 1 silently — pwsh works fine outside CC[Bug] Windows: PowerShell tool returns Exit 1 silently — pwsh works fine outside CC [1 comments, 2 participants]