claude-code - 💡(How to fix) Fix Shell snapshot filters _-prefixed functions, breaking dependent exported functions (GVM _encode/_decode) [2 comments, 2 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#55985Fetched 2026-05-05 06:01:09
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

Claude Code's shell snapshot mechanism filters out shell functions whose names start with _. This causes breakage when exported functions (which are captured in the snapshot) internally call _-prefixed helpers (which are not captured).

Root Cause

In ~/.claude/shell-snapshots/snapshot-zsh-*.sh, functions like setValueForKeyFakeAssocArray and valueForKeyFakeAssocArray are present (they don't start with _), but _encode and _decode — which they depend on — are absent because the snapshot capture filters all _-prefixed function names.

The snapshot files are consistently 6997 lines and do not contain a single ^_[a-z] function definition, confirming the filter is applied broadly.

Code Example

setValueForKeyFakeAssocArray:27: command not found: _encode
valueForKeyFakeAssocArray:28: command not found: _decode
RAW_BUFFERClick to expand / collapse

Description

Claude Code's shell snapshot mechanism filters out shell functions whose names start with _. This causes breakage when exported functions (which are captured in the snapshot) internally call _-prefixed helpers (which are not captured).

Steps to Reproduce

  1. Install GVM (Go Version Manager)
  2. Source GVM in ~/.zshrc: [[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
  3. Open Claude Code and run any bash command that triggers a cd call

What Happens

GVM overrides the cd shell function. This override calls setValueForKeyFakeAssocArray (captured in snapshot), which in turn calls _encode/_decode (defined in ~/.gvm/scripts/function/_bash_pseudo_hash, filtered from snapshot).

Every bash command that causes a directory change produces:

setValueForKeyFakeAssocArray:27: command not found: _encode
valueForKeyFakeAssocArray:28: command not found: _decode

Root Cause

In ~/.claude/shell-snapshots/snapshot-zsh-*.sh, functions like setValueForKeyFakeAssocArray and valueForKeyFakeAssocArray are present (they don't start with _), but _encode and _decode — which they depend on — are absent because the snapshot capture filters all _-prefixed function names.

The snapshot files are consistently 6997 lines and do not contain a single ^_[a-z] function definition, confirming the filter is applied broadly.

Expected Behavior

The snapshot should either:

  • Follow function call dependencies and include _-prefixed functions that are called by captured functions, or
  • Not filter _-prefixed functions from the snapshot at all (they are legitimate shell functions, not internal shell builtins)

Impact

  • Stderr noise on every bash command involving cd
  • GVM's Go version auto-switching fails silently in Claude Code's bash context
  • Affects any user with shell setups where public functions depend on _-prefixed helpers (GVM, some zsh plugins, custom scripts)

Environment

  • macOS Darwin 25.4.0 (arm64)
  • Shell: zsh
  • GVM installed at ~/.gvm
  • Claude Code CLI

extent analysis

TL;DR

The issue can be resolved by modifying the Claude Code's shell snapshot mechanism to either include _-prefixed functions or follow function call dependencies.

Guidance

  • Identify the specific functions in the snapshot that call _-prefixed helpers and manually add those helpers to the snapshot.
  • Consider modifying the snapshot capture script to recursively include all functions called by captured functions, regardless of their prefix.
  • Verify the fix by checking the snapshot files for the presence of _encode and _decode functions and ensuring that GVM's Go version auto-switching works correctly in Claude Code's bash context.
  • If modifying the snapshot mechanism is not feasible, consider using a different shell setup that does not rely on _-prefixed helpers.

Example

No code snippet is provided as the issue is related to the shell snapshot mechanism and not a specific code block.

Notes

The solution may require modifications to the Claude Code CLI or the GVM installation, and may not be applicable to all users with similar shell setups.

Recommendation

Apply a workaround by manually adding the required _-prefixed functions to the snapshot, as modifying the snapshot mechanism may require significant changes to the underlying code.

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