Shell Snapshot Generation: Malformed Alias Causing Syntax Error

Status Fixed / completed
Maintainer reply ✓ Yes — ant-kurt
Activity 6 comments · opened Aug 2, 2025 · closed Nov 28, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

Bug Description

Claude Code Shell Snapshot Bug Report

Summary

Claude Code generates malformed shell snapshot files that prevent any bash commands from executing, causing all Bash tool invocations to fail with "unmatched ' " error.

Environment

  • Platform: Windows (MINGW64_NT-10.0-26100)
  • Claude Code Version: Latest (as of 2025-08-02)
  • Shell: zsh
  • User: username (no spaces in username)

Issue Description

Every attempt to use the Bash tool in Claude Code fails with the following error:

/c/Users/username/.claude/shell-snapshots/snapshot-zsh-[timestamp]-[id].sh:8: unmatched '

Root Cause

Examination of the generated snapshot file reveals a malformed alias line:

# Check for rg availability
if ! command -v rg >/dev/null 2>&1; then
  alias rg=''\''Z:fi

Additional Information

  • Generated snapshot file path: /c/Users/username/.claude/shell-snapshots/snapshot-zsh-[timestamp]-[id].sh
  • Error occurs at line 8 of snapshot file
  • Issue prevents normal development workflow using Claude Code tools

---
Report generated: 2025-08-02
Status: Blocking all bash command execution in Claude Code

Environment Info

  • Platform: win32
  • Terminal: vscode
  • Version: 1.0.67
  • Feedback ID: 66581ba0-f44b-4cd7-a320-6d6a468cda0a

Errors

[{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:1474:421\n    at Object.useMemo (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:65:26368)\n    at $$9.useMemo (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:46:15588)\n    at lV (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:1474:313)\n    at KR (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:65:19859)\n    at Mb (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:42848)\n    at Nb (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38369)\n    at Bj (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38297)\n    at _R (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38151)\n    at MC (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:35214)","timestamp":"2025-08-02T19:20:58.935Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:1474:421\n    at Object.useMemo (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:65:26368)\n    at $$9.useMemo (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:46:15588)\n    at lV (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:1474:313)\n    at KR (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:65:19859)\n    at Mb (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:42848)\n    at Nb (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38369)\n    at Bj (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38297)\n    at _R (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claude-code/cli.js:67:38151)\n    at MC (file:///Z:/clang64/lib/node_modules/@anthropic-ai/claud

Note: Error logs were truncated.

View original on GitHub ↗

6 Comments

github-actions[bot] · 1 year ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/1872
  2. https://github.com/anthropics/claude-code/issues/4148
  3. https://github.com/anthropics/claude-code/issues/3676

If your issue is a duplicate, please close it and 👍 the existing issue instead.

🤖 Generated with Claude Code

ant-kurt collaborator · 1 year ago

Hi @eric-handley, can you help me understand your configuration? What values do you have for env vars SHELL and CLAUDE_CODE_GIT_BASH_PATH - how did you set up zsh with mingw?

This may be a zsh-specific issue, if you want to try bash to mitigate.

eric-handley · 1 year ago

Hi @ant-kurt, I have a separate Windows Dev Drive (Z:) using MSYS2 so SHELL="/z/usr/bin/zsh" and CLAUDE_CODE_GIT_BASH_PATH="Z:\usr\bin\zsh.exe"

My temporary fix for this has just been to set up a script to remove the following lines (888 - 892) from cli.js:

# Check for rg availability
echo "# Check for rg availability" >> "$SNAPSHOT_FILE"
echo "if ! command -v rg >/dev/null 2>&1; then" >> "$SNAPSHOT_FILE"
echo '  alias rg='"'${B.replace(/'/g,"'\\''")}'" >> "$SNAPSHOT_FILE"
echo "fi" >> "$SNAPSHOT_FILE"
bastien70 · 1 year ago

Hello, I've the same problem, I used this commands :

CLI_JS20="$HOME/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js"
cp -v "$CLI_JS20" "${CLI_JS20}.bak"
grep -n "Check for rg availability" "$CLI_JS20"
sed -i -e '/Check for rg availability/,+4d' "$CLI_JS20"
rm -rf ~/.claude/shell-snapshots/*

It worked fine, but 15 minutes later, idk why, the problem is showing, and if I relaunch the commands, it doesn't change anything

eric-handley · 10 months ago

I haven't run into this issue in a long time and it doesn't look like there's any activity on this or many people with the same issue

github-actions[bot] · 10 months ago

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.