[BUG] Shell Snapshot cause incorrect environment loaded

Status Fixed / completed
Maintainer reply ✓ Yes — wolffiex
Activity 6 comments · opened Jul 11, 2025 · closed Jul 14, 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: 1.0.48 (Claude Code)
  • Operating System: macOS 15.4.1
  • Terminal: Ghostty + tmux + zsh

Bug Description

The shell snapshot feature causes the environment lookup to be incorrect.

Steps to Reproduce

When I work with 2 directories with uv venv feature:

/project_a/.venv
/project_b/.venv

I run the claude to enter Claude Code at /project_a and it snapshots the PATH=/project_a/.venv/bin. Then, I switch to /project_b and enter the Claude Code, the PATH is still PATH=/project_a/.venv/bin cannot be changed to PATH=/project_b/.venv/bin

Expected Behavior

Switch to another directory, it should follow the shell's environment instead of the "first enter claude shell" status.

Actual Behavior

When entering Claude at any shell, it always uses the same configuration and cannot be changed unless the snapshot file is removed. It causes many environment-based config losses and cannot work with the correct terminal config.

Additional Context

<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->

View original on GitHub ↗

6 Comments

thoughtpolice · 1 year ago

Yeah, this is pretty bad if you use something like direnv as well since your entire shell is different quite regularly. I'm guessing this is a regression in 1.0.48 which has this changelog entry:

- Moved shell snapshots from /tmp to ~/.claude for more reliable Bash tool calls

One of my machines is still running 1.0.44 which has no issues.

wolffiex collaborator · 1 year ago

Sorry for this regression. This was an unintended side effect of fixing #2139
We'll get a fix out for this on Monday

thoughtpolice · 1 year ago

Thanks! Rolling back a huge issue on my end. Have a good weekend.

elct9620 · 1 year ago

@wolffiex

After upgrading to 1.0.51, I still got an incorrect environment. Is it fixed?

wolffiex collaborator · 1 year ago

yes, please upgrade to 1.0.56 and open a new issue if you're still having problems

github-actions[bot] · 1 year 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.