[BUG] Git Commands Fail with error: claude-shell-snapshot-4824:1716: parse error near ()'
Resolved 💬 23 comments Opened Apr 14, 2025 by cromulus Closed Apr 21, 2025
💡 Likely answer: A maintainer (wolffiex, collaborator)
responded on this thread — see the highlighted reply below.
Environment
- Platform (select one):
- [X] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 0.2.69 (Claude Code)
- Operating System: Mac OSX 15.3.2
- Terminal: iTerm2
Bug Description
After a recent update, Claude Code is no longer able to execute git commands. Constantly get this error:
Bash(git diff master)…
⎿ /var/folders/yq/fkn_qw293fgfr3vz7jmnjxpw0000gn/T/claude-shell-snapshot-4824:1716: defining function based on alias `run-help'
/var/folders/yq/fkn_qw293fgfr3vz7jmnjxpw0000gn/T/claude-shell-snapshot-4824:1716: parse error near `()'
Steps to Reproduce
- Open Claude in a git repo
- Ask Claude to perform a git command
- Receive Error
Expected Behavior
I expect Claude to be able to perform git commands.
Actual Behavior
Error out, received the errors above.
Additional Context
- git version 2.49.0
- zsh 5.9 (arm-apple-darwin21.3.0)
This may be occurring with other commands, I just happened to notice it with git.
Claude can read files, and edit files just fine though.
23 Comments
Additional details:
Environment Info
Errors
I believe it's the Bash tool, not just git commands:
```> What directory are we in?
⏺ Bash(pwd)…
⎿ /var/folders/m5/s6x3rp3d4xx83l4wx1rmg0gc0000gn/T/claude-shell-snapshot-943f:4277: defining function based on alias
run-help'()'/var/folders/m5/s6x3rp3d4xx83l4wx1rmg0gc0000gn/T/claude-shell-snapshot-943f:4277: parse error near
⏺ Bash(cd /Users/rodk/work/atlas-up-ai && pwd)…
⎿ /var/folders/m5/s6x3rp3d4xx83l4wx1rmg0gc0000gn/T/claude-shell-snapshot-943f:4277: defining function based on alias
run-help'()'/var/folders/m5/s6x3rp3d4xx83l4wx1rmg0gc0000gn/T/claude-shell-snapshot-943f:4277: parse error near
Rolling back to v0.2.68 eliminated the issue.
This issue started happening for me today as well. It isn't just git, though -- for me it started happening when running
Bash(yarn prettier --write filename).With
SHELL=/bin/bash claudethe issue doesn't reproduce, but does with zsh + zprezto, and the problem is definitely withsource "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"in my .zshrc file, as if I comment it out, everything starting working again after claude code restart.In init.sh,
(( $+aliases[run-help] )) && unalias run-help && autoload -Uz run-helpis the line which causes trouble for Claude.In my zsh with zprezto loaded as usual:
This is precisely what is written at the problematic line in claude-shell-snapshot file it mentions as problematic, it chokes on that function.
Simple workaround for now, in your .zshrc find
init.zshinvokation and replace it with:I happen to find that CLAUDECODE is distinct env variable set during run of the shell commands by Claude Code:
thanks for this detailed report! would you mind including the complete contents of your /var/folders/yq/fkn_qw293fgfr3vz7jmnjxpw0000gn/T/claude-shell-snapshot-4824:1716 or similar?
This is the new shell implementation we shipped last friday.
For posterity, this solution worked for me 👍🏼 🙏🏼
I am not using zprezto, but have this issue. Setting
SHELL=/bin/bash clauderesolves it, though, so it's most likely because of _something_ in my .zshrc. The issue is still present in 0.2.70.if anyone can share the contents of their snapshot file (looks like
/var/folders/m5/s6x3rp3d4xx83l4wx1rmg0gc0000gn/T/claude-shell-snapshot-943f) that would be super helpfulHi everyone. In my case, I'm experiencing a slightly different error message compared to yours, but it appears to be related to the same issue.
I'm using bash shell with iTerm on macOS, and here's what I'm seeing:
I hope I won't regret it.
claude-shell-snapshot-5256.txt
I’m running into the same issue. Setting
SHELL=/bin/bash claude, as @paskal suggested, worked as a temporary workaround for me too.I wanted to contribute by adding that the problem happens on bash for me.
SHELL=/bin/bash claudedoesn't help.The problematic line seems to be
| sed 's/\\\[\\033/ESC/g' | sed 's/\\\]//g'bear the end of that snippet in/var/folders/q1/7vbmgf455wldzb2svh1q5z440000gn/T/claude-shell-snapshot-1e17.For folks where switching to bash helps, this is probably because the issue is with your zshrc. The alternative is to condition problematic parts of your .zshrc on
if [[ -z "${CLAUDECODE}" ]]; then
This will be set when Claude Code is sourcing your config and presumably not set otherwise
@siovene can you please share the original definition of git_prompt_examples from your .bashrc?
ok we have a fix for "defining function based on alias" that should go out tomorrow
there was an additional issue with rc files that trapped exit signals which should also be fixed
an example of a bash function that we are not capturing correctly would be super helpful
@wolffiex the issue was this in my .bashprofile:
Solved by using
if [[ -z "${CLAUDECODE}" ]]; thento exclude it:thanks for the reference @siovene ! I think I have this fix for this. Should roll out on Monday at the latest.
Works in 0.2.76 for me.
ok I think this should be fixed with 0.2.76
Looking at #1849, it may be difficult to fix all the issues. For example, in my case, I have in the snapshot:
It's not possible to declare
=as an alias. In my original zshrc, I use a workaround:I don't mind Claude not being able to run commands exactly as I do. Most of my zshrc aliases are sugarcoat. I suppose I could put a test on
CLAUDECODEsomewhere, but I suppose we would be many stubbling into such problems. Could we just opt-out of this behavior?This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.