claude-code - 💡(How to fix) Fix Windows: PowerShell permission classifier fails 'command line too long' when additionalDirectories list is large [1 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#55671Fetched 2026-05-03 04:47:28
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×4

On Windows, CC's PowerShell permission classifier can crash with pwsh exited with code 1: The command line is too long when permissions.additionalDirectories (or other long settings fields) accumulate enough entries to push the pwsh subprocess invocation past the Windows CreateProcess 32,767-character command-line limit. When this happens, every PowerShell tool call is denied — including allowlisted commands and trivially safe ones like Get-ChildItem . — making the PowerShell(...) allowlist effectively non-functional.

Root Cause

On Windows, CC's PowerShell permission classifier can crash with pwsh exited with code 1: The command line is too long when permissions.additionalDirectories (or other long settings fields) accumulate enough entries to push the pwsh subprocess invocation past the Windows CreateProcess 32,767-character command-line limit. When this happens, every PowerShell tool call is denied — including allowlisted commands and trivially safe ones like Get-ChildItem . — making the PowerShell(...) allowlist effectively non-functional.

Fix Action

Fix / Workaround

Workaround for affected users

Code Example

permission denials: ["pwsh exited with code 1: The command line is too long."]
RAW_BUFFERClick to expand / collapse

Summary

On Windows, CC's PowerShell permission classifier can crash with pwsh exited with code 1: The command line is too long when permissions.additionalDirectories (or other long settings fields) accumulate enough entries to push the pwsh subprocess invocation past the Windows CreateProcess 32,767-character command-line limit. When this happens, every PowerShell tool call is denied — including allowlisted commands and trivially safe ones like Get-ChildItem . — making the PowerShell(...) allowlist effectively non-functional.

Repro (this install)

  • OS: Windows 11 Pro 10.0.26200
  • CC: 2.1.126 (VSCodium extension) + standalone CLI binary
  • pwsh: 7.6.1 (Microsoft Store install)
  • CLAUDE_CODE_USE_POWERSHELL_TOOL=1 set in env + ~/.claude/settings.json
  • additionalDirectories: 38 entries (including duplicates — ~/.claude/... Unix-style + C:\Users\...\.claude\... Windows-backslash + c:/Users/... Windows-forward-slash forms — which CC normalizes to the same POSIX path internally per docs but stores as separate string entries)

Symptom (reproduced empirically across 6 probes via claude -p --model haiku --output-format json --allowedTools "PowerShell"):

permission denials: ["pwsh exited with code 1: The command line is too long."]

Symptom appeared on every probe regardless of allowlist content. Pruning additionalDirectories from 38 → 4 entries restored expected behavior.

Expected vs actual

  • Expected: allowlisted PowerShell commands auto-approve; non-allowlisted prompt or deny per pattern matching.
  • Actual: classifier subprocess fails before any pattern matching runs; all PowerShell calls denied uniformly.

Suggested fix

The permission classifier should not embed the full settings context (especially additionalDirectories, permissions.allow/deny/ask lists, etc.) into the pwsh -Command/-ArgumentList invocation. Pipe via stdin or write to a temp file instead — both bypass the CreateProcess arg-length limit.

Workaround for affected users

Audit additionalDirectories and dedupe / drop redundant entries. CC docs (https://code.claude.com/docs/en/permissions#additional-directories-grant-file-access-not-configuration) confirm directory entries subsume children, and Windows paths normalize to POSIX form internally — most multi-form lists can collapse to a few parent entries.

Related

extent analysis

TL;DR

The most likely fix is to modify the permission classifier to pipe settings via stdin or write to a temp file instead of embedding them in the pwsh invocation to bypass the Windows CreateProcess command-line limit.

Guidance

  • Review and dedupe additionalDirectories entries to minimize the number of entries, as redundant entries can contribute to the command-line length limit issue.
  • Consider implementing the suggested fix of piping settings via stdin or writing to a temp file to avoid the command-line length limit.
  • Verify the fix by testing with a large number of additionalDirectories entries and checking that allowlisted PowerShell commands are approved as expected.
  • If implementing the fix is not feasible, apply the workaround of auditing and deduping additionalDirectories entries to reduce the command-line length.

Example

No code snippet is provided as the issue does not require a specific code example to understand the solution.

Notes

The fix may require modifications to the permission classifier code, and the workaround may not be suitable for all users, especially those with complex directory structures.

Recommendation

Apply the workaround of auditing and deduping additionalDirectories entries to reduce the command-line length, as this is a simpler and more immediate solution that can help mitigate the issue until a permanent fix is implemented.

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