claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Claude stops with snapshot error

Open derekbreden opened this issue 1 year ago • 43 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [x] Other: Pro max plan, not billed per API usage
  • Claude CLI version: 1.0.24 (Claude Code)
  • Operating System: macOS 15.5 (24F74)
  • Terminal: Terminal 2.14

Bug Description

Steps to Reproduce

  1. I have not been able to reproduce the issue

Expected Behavior

Claude does not get stuck in a loop with:

⏺ Bash(npm test client-server)
  ⎿  Error: zsh:source:1: no such file or directory: /var/folders/qc/hn57tpxs7tg5842pdqg075vc0000gn/T/claude-shell-snapshot-c1b9

⏺ Bash(npm test client-server)
  ⎿  Error: zsh:source:1: no such file or directory: /var/folders/qc/hn57tpxs7tg5842pdqg075vc0000gn/T/claude-shell-snapshot-c1b9

⏺ Bash(npm test client-server)
  ⎿  Error: zsh:source:1: no such file or directory: /var/folders/qc/hn57tpxs7tg5842pdqg075vc0000gn/T/claude-shell-snapshot-c1b9

⏺ Bash(npm test client-server)
  ⎿  Error: zsh:source:1: no such file or directory: /var/folders/qc/hn57tpxs7tg5842pdqg075vc0000gn/T/claude-shell-snapshot-c1b9

Actual Behavior

Claude was no longer able to execute any shell commands, every shell command attempted produce the "no such file or directory.

Additional Context

I did have 104GB free on my drive. I suspect there is some cleanup operation, and it seems unlikely to be a macOS one from my naive understanding, but I really know nothing about this.

d0e33c75-2e65-425a-8bb5-146e87c1d570.jsonl.txt

relevant text from claude from my perspective.txt

Image Image

As seen in the screenshot, Claude said "You could report this as a bug", so I did.

derekbreden avatar Jun 16 '25 08:06 derekbreden

I've noticed the same thing. It seems to happen when you return to an old session. Restarting the session fixes it.

elyase avatar Jun 16 '25 15:06 elyase

Interesting.

In my case there was a less than 30 minute, perhaps 5 minute (just guessing based on memory) delay between when the shell was working and when it stopped working. It was all within one prompt response from Claude. It was working when Claude first started responding and part way through the response its "shell" broke.

The .jsonl log I attached might confirm this? I don't know what all is included in those logs, or if there is a different one I should attach.

derekbreden avatar Jun 16 '25 15:06 derekbreden

I'm experiencing the same issue. For me, it happens even in fresh sessions and is often so persistent that opening new sessions doesn't resolve it.

Details

I initially suspected it was due to working with multiple Claude Code sessions simultaneously (using git worktrees), but testing after killing all Claude processes showed this wasn't the cause. I also found stale processes in Activity Monitor after closing sessions, but killing them didn't help either.

Honestly, this happens more often than not for me.

The only reason I'm still using Claude Code is my recent Max plan subscription - Cursor seems more expensive currently, but that might change.

I also suspected it might be related to using ZSH with oh-my-zsh (saw someone mention this), but it occurs in bash too.

Actually, I didn't know how to switch to bash in my particular scenario.

Solution

I created a completely separate, streamlined environment specifically for Claude Code:

  • Uses bash instead of zsh
  • No Homebrew or mise contamination
  • Only direct installations of required tools (Node.js, etc.)
  • Force Claude Code to run through bash with export SHELL=/bin/bash

It's not ideal, but it works reliably, and I'll keep it this way until this gets resolved in Claude Code.

almirsarajcic avatar Jun 22 '25 09:06 almirsarajcic

Also suffering this issue when claude code shells are left idle.

markng avatar Jun 25 '25 19:06 markng

Feels good to know I'm not alone. If I restart the terminal window and Claude code, does it still have access to the prior session context?

amiperl avatar Jun 26 '25 13:06 amiperl

You can use /resume command to continue one of the previous sessions. There's even -c flag (claude -c) to resume the very last one.

almirsarajcic avatar Jun 26 '25 14:06 almirsarajcic

It worked for a while, but since one of the latest updates (maybe 1.0.38), it doesn't work even with the fix (https://github.com/anthropics/claude-code/issues/2139#issuecomment-2994060105).

Sometimes it runs a command, but after a few commands, it stops working. Or sometimes doesn't work at all. Only restarting helps, but that's far from ideal for any longer work.

Image

almirsarajcic avatar Jul 03 '25 07:07 almirsarajcic

I can confirm I run into this error. It appears to only happen when CC is updated in the background, and your active session is using an old version.

PastaPastaPasta avatar Jul 06 '25 16:07 PastaPastaPasta

I'm seeing this error too, but it seems to happen all the time (after a minute or two of coding) - not just when CC is updated in the background. I've tried to use bash as the shell (rather than zsh) and this doesn't seem to make any difference

oco-adam avatar Jul 07 '25 12:07 oco-adam

Same for me. After a few minutes of usage, Claude Code becomes pretty much useless to me. Can't wait for opencode to reach feature parity. I won't touch Claude Code. I'm even considering going back to Cursor at this point :/

I switched from Cursor to Claude Code 2-3 weeks ago, and in total, I've had it working for maybe 3 days in total. Everything else was a struggle. I'll try using Docker containers. If that doesn't work, bye bye Claude Code.

almirsarajcic avatar Jul 08 '25 08:07 almirsarajcic

It took me a while to set Docker containers up, but even there, I have this issue. It's crazy. I've tried 3 kinda completely different environments and I still get this issue. And I'm not the only one. So I'm pretty sure now it's not PEBCAK.

Let me know if you need any additional info about my environment. Until then, I'll be using opencode.

almirsarajcic avatar Jul 08 '25 15:07 almirsarajcic

This happens to me anytime I close the session and reopen it without restarting the entire terminal. Would nice to be able to manually clear those snapshot temp files or something. For reference, I use Kitty terminal

shallow-alchemy avatar Jul 09 '25 19:07 shallow-alchemy

Guys, I think you need to hear this.

As someone who's been struggling with this for the past few weeks, this morning I switched to opencode and I have the same feeling of leveling up like I've had when I moved from Cursor's Chat to Claude Code.

Ramble The reason I hesitated switching so much was that I have a pretty complex automated workflow.

It involves creating a new Cursor/VS Code workspace for every feature I work on, deals with memory files (plans, contexts...), and runs tests/code checks as part of the feedback loop.

So I asked opencode to convert my scripts. After like 15 minutes and just one small manual change, I can now switch from Claude Code to opencode and back easily. I don't even care what's driving the agent as long as it works.

Hopefully, one day, this bug in Claude Code gets fixed, and then I'll only care which model I'll be using, not the terminal tooling.

But if all goes well with opencode, I don't think I'll come back.

Anyway, try opencode. You'll thank me later.

almirsarajcic avatar Jul 10 '25 10:07 almirsarajcic

Thanks Almir. I just heard about this: https://github.com/NomenAK/SuperClaude - seems to sit on top of Claude code - maybe through this you may not have the same issues...

amiperl avatar Jul 10 '25 10:07 amiperl

As of v1.0.48 we moved the shell snapshot to ~/.claude/shell-snapshots This should make it easier to inspect and even edit the shell snapshot. It should also prevent the OS from cleaning up the snapshot while you're using it. Can you please test and let us know how it goes?

wolffiex avatar Jul 10 '25 19:07 wolffiex

Doesn't show up anymore. Thanks!

almirsarajcic avatar Jul 11 '25 06:07 almirsarajcic

still shows up for me even after repeated restarts

shallow-alchemy avatar Jul 11 '25 17:07 shallow-alchemy

@shallow-alchemy can you post the new error message?

wolffiex avatar Jul 11 '25 17:07 wolffiex

Yeah. I just noticed its slightly different now

Image

Want me to open a new issue? (to be clear, the missing error seems resolved)

shallow-alchemy avatar Jul 11 '25 18:07 shallow-alchemy

interesting, can you please post the relevant line from that file? here's fine

wolffiex avatar Jul 11 '25 18:07 wolffiex