claude-code - 💡(How to fix) Fix [BUG] Bash tool: exit 126 with "permission denied: /proc/self/fd/3" on Fedora 43 + zsh, blocks git writes, `ls -la`, `gh` [4 comments, 4 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#51865Fetched 2026-04-23 07:42:50
View on GitHub
Comments
4
Participants
4
Timeline
14
Reactions
3
Timeline (top)
commented ×4labeled ×4subscribed ×4cross-referenced ×2

On Fedora Linux 43 with zsh as the default shell, Claude Code's Bash tool returns exit code 126 for a reproducible subset of commands, including git checkout, git push, gh pr create, ls -la <pattern>, and find. Simpler commands in the same session (pwd, git status, grep, Read/Edit tool file operations) work normally. The error surfaces in the harness as:

  Exit code 126
  [Request interrupted by user for tool use]

— but the user did not interrupt. A previous CC session on this machine surfaced the underlying error: zsh:4: permission denied: /proc/self/fd/3, indicating zsh's shell init is failing on a specific file-descriptor access inside whatever sandbox CC spawns the shell under.

Restarting the Claude Code tab (as suggested by CC docs for CLI failures) does not resolve this. Subagents dispatched via the Agent tool (git-master, coder, finder) hit the identical failure — the block is at the harness/sandbox boundary, not the CLI.

Environment

  • Claude Code version: <paste claude --version output>
  • OS: <paste /etc/os-release NAME + VERSION>
  • Kernel: Linux 6.19.12-200.fc43.x86_64
  • Shell: zsh (<paste $SHELL + zsh --version>)
  • Model: claude-opus-4-7 (1M context)
  • Project has a PreToolUse Bash hook (.claude/hooks/guard-bash.sh) — confirmed narrow (only blocks inline-secret patterns), not the cause.

Works vs. doesn't

Works in the same session:

  • pwd
  • git status --short | head -20
  • git log --oneline -3
  • git branch --show-current && git stash list | head -5
  • grep -n -E 'pattern' path/to/file.toml
  • All Read / Edit / Write tool operations

Fails with exit 126:

  • ls -la <glob-with-dotfiles>
  • find . -maxdepth 2 -name '.env*'
  • git checkout -b new/branch
  • git push origin branch
  • gh pr create ...
  • /usr/bin/git checkout -b new/branch (absolute path — same failure)

Error Message

tool file operations) work normally. The error surfaces in the harness as: surfaced the underlying error: zsh:4: permission denied: /proc/self/fd/3,

Error Messages/Logs

Root Cause

On Fedora Linux 43 with zsh as the default shell, Claude Code's Bash tool returns exit code 126 for a reproducible subset of commands, including git checkout, git push, gh pr create, ls -la <pattern>, and find. Simpler commands in the same session (pwd, git status, grep, Read/Edit tool file operations) work normally. The error surfaces in the harness as:

  Exit code 126
  [Request interrupted by user for tool use]

— but the user did not interrupt. A previous CC session on this machine surfaced the underlying error: zsh:4: permission denied: /proc/self/fd/3, indicating zsh's shell init is failing on a specific file-descriptor access inside whatever sandbox CC spawns the shell under.

Restarting the Claude Code tab (as suggested by CC docs for CLI failures) does not resolve this. Subagents dispatched via the Agent tool (git-master, coder, finder) hit the identical failure — the block is at the harness/sandbox boundary, not the CLI.

Environment

  • Claude Code version: <paste claude --version output>
  • OS: <paste /etc/os-release NAME + VERSION>
  • Kernel: Linux 6.19.12-200.fc43.x86_64
  • Shell: zsh (<paste $SHELL + zsh --version>)
  • Model: claude-opus-4-7 (1M context)
  • Project has a PreToolUse Bash hook (.claude/hooks/guard-bash.sh) — confirmed narrow (only blocks inline-secret patterns), not the cause.

Works vs. doesn't

Works in the same session:

  • pwd
  • git status --short | head -20
  • git log --oneline -3
  • git branch --show-current && git stash list | head -5
  • grep -n -E 'pattern' path/to/file.toml
  • All Read / Edit / Write tool operations

Fails with exit 126:

  • ls -la <glob-with-dotfiles>
  • find . -maxdepth 2 -name '.env*'
  • git checkout -b new/branch
  • git push origin branch
  • gh pr create ...
  • /usr/bin/git checkout -b new/branch (absolute path — same failure)

Fix Action

Fix / Workaround

Restarting the Claude Code tab (as suggested by CC docs for CLI failures) does not resolve this. Subagents dispatched via the Agent tool (git-master, coder, finder) hit the identical failure — the block is at the harness/sandbox boundary, not the CLI.

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?

Summary

On Fedora Linux 43 with zsh as the default shell, Claude Code's Bash tool returns exit code 126 for a reproducible subset of commands, including git checkout, git push, gh pr create, ls -la <pattern>, and find. Simpler commands in the same session (pwd, git status, grep, Read/Edit tool file operations) work normally. The error surfaces in the harness as:

  Exit code 126
  [Request interrupted by user for tool use]

— but the user did not interrupt. A previous CC session on this machine surfaced the underlying error: zsh:4: permission denied: /proc/self/fd/3, indicating zsh's shell init is failing on a specific file-descriptor access inside whatever sandbox CC spawns the shell under.

Restarting the Claude Code tab (as suggested by CC docs for CLI failures) does not resolve this. Subagents dispatched via the Agent tool (git-master, coder, finder) hit the identical failure — the block is at the harness/sandbox boundary, not the CLI.

Environment

  • Claude Code version: <paste claude --version output>
  • OS: <paste /etc/os-release NAME + VERSION>
  • Kernel: Linux 6.19.12-200.fc43.x86_64
  • Shell: zsh (<paste $SHELL + zsh --version>)
  • Model: claude-opus-4-7 (1M context)
  • Project has a PreToolUse Bash hook (.claude/hooks/guard-bash.sh) — confirmed narrow (only blocks inline-secret patterns), not the cause.

Works vs. doesn't

Works in the same session:

  • pwd
  • git status --short | head -20
  • git log --oneline -3
  • git branch --show-current && git stash list | head -5
  • grep -n -E 'pattern' path/to/file.toml
  • All Read / Edit / Write tool operations

Fails with exit 126:

  • ls -la <glob-with-dotfiles>
  • find . -maxdepth 2 -name '.env*'
  • git checkout -b new/branch
  • git push origin branch
  • gh pr create ...
  • /usr/bin/git checkout -b new/branch (absolute path — same failure)

What Should Happen?

Expected

Bash tool executes the command in a shell environment that zsh can initialize successfully, or falls back to bash / sh if the user shell fails to init. Exit code should reflect the actual command exit, not a shell-init failure disguised as a user interrupt.

Error Messages/Logs

Steps to Reproduce

Reproduction

  1. cd into a git repository on Fedora 43 with zsh as the user shell.
  2. Ask Claude Code to run git checkout -b any/branch-name via the Bash tool.
  3. Observe exit code 126 with "Request interrupted by user for tool use" even when the user does nothing.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.117 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

❯ claude --version 2.1.117 (Claude Code)

~ ❯ cat /etc/os-release | head -4 NAME="Fedora Linux" VERSION="43 (Workstation Edition)" RELEASE_TYPE=stable ID=fedora

~ ❯ echo $SHELL && zsh --version /usr/bin/zsh zsh 5.9 (x86_64-redhat-linux-gnu)

extent analysis

TL;DR

The issue can be resolved by modifying the shell initialization or the Claude Code's Bash tool to handle the permission denied error on /proc/self/fd/3 when using zsh as the default shell.

Guidance

  • Investigate the zsh shell initialization process to identify why it's failing on the specific file-descriptor access, potentially related to the PreToolUse Bash hook or the sandbox environment.
  • Consider adding a fallback to use bash or sh if zsh initialization fails, to ensure the Bash tool executes commands successfully.
  • Review the Claude Code documentation for any specific configuration options or environment variables that can be set to handle shell initialization issues.
  • Test the Bash tool with a different shell, such as bash, to isolate the issue to zsh or the Claude Code environment.

Example

No specific code example is provided, as the issue is related to the interaction between zsh, Claude Code, and the sandbox environment.

Notes

The issue is specific to Fedora Linux 43 with zsh as the default shell, and the solution may not apply to other environments. The PreToolUse Bash hook is confirmed not to be the cause, but its presence may still be relevant to the shell initialization process.

Recommendation

Apply a workaround by modifying the shell initialization or the Claude Code's Bash tool to handle the permission denied error, as the root cause is not explicitly stated and may require further investigation.

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