[Bug] Shell snapshot doesn't capture zsh hook arrays (chpwd_functions, precmd_functions)
Bug Description
Title: Bash tool shell snapshot doesn't capture chpwd_functions / precmd_functions, breaking zoxide and similar tools
Environment:
- Claude Code on macOS (Darwin 25.3.0), zsh
- zoxide 0.9.8, initialized via eval "$(zoxide init zsh --cmd cd)" at the end of ~/.zshrc
Symptom:
Every cd invocation in the Bash tool prints:
zoxide: detected a possible configuration issue.
Please ensure that zoxide is initialized right at the end of your shell configuration file (usually ~/.zshrc).
The advice is a false positive — zoxide is at the end of .zshrc.
Root cause:
The Bash tool replays a shell snapshot at ~/.claude/shell-snapshots/snapshot-zsh-*.sh instead of sourcing .zshrc fresh. The snapshot captures function definitions (including __zoxide_hook, __zoxide_doctor, cd) but does not capture the chpwd_functions array. So __zoxide_hook is defined but never registered.
zoxide's __zoxide_doctor (called on every cd) checks chpwd_functions[(Ie)__zoxide_hook] -eq 0 and emits the warning when the hook isn't registered.
Side effect beyond the warning: Directory changes inside Bash-tool shells aren't recorded to the zoxide frecency database. Any tool that relies on chpwd_functions, precmd_functions, or preexec_functions (direnv, asdf, starship, etc.) is similarly affected.
Suggested fix:
In the snapshot generator, also serialize the chpwd_functions, precmd_functions, and preexec_functions arrays (and re-add-zsh-hook them on replay), not just function bodies.
Workaround for users: export _ZO_DOCTOR=0 in ~/.zshenv.
Environment Info
- Platform: darwin
- Terminal: tmux
- Version: 2.1.139
- Feedback ID: 2ba44988-7d62-4f59-a239-b51e4e6f1211
Errors
[{"error":"AxiosError: Request failed with status code 401\n at hr (/$bunfs/root/src/entrypoints/cli.js:116:1194)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:121:12716)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:865:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/src/entrypoints/cli.js:123:2467)\n at async <anonymous> (/$bunfs/root/src/entrypoints/cli.js:9425:20616)\n at async BN (/$bunfs/root/src/entrypoints/cli.js:420:5360)\n at async rn3 (/$bunfs/root/src/entrypoints/cli.js:9425:20373)\n at async hQK (/$bunfs/root/src/entrypoints/cli.js:9425:21133)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-05-14T08:16:04.076Z"},{"error":"Error: 401 {\"type\":\"error\",\"error\":{\"type\":\"authentication_error\",\"message\":\"Invalid authentication credentials\"},\"request_id\":\"req_011Cb28e5Gp9Zjj2vjH9mwgf\"}\n at generate (/$bunfs/root/src/entrypoints/cli.js:11:59523)\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:51:7694)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-05-14T08:18:22.382Z"},{"error":"Error: 401 {\"type\":\"error\",\"error\":{\"type\":\"authentication_error\",\"message\":\"Invalid authentication credentials\"},\"request_id\":\"req_011Cb28e4rm4fjEUxChUbcyB\"}\n at generate (/$bunfs/root/src/entrypoints/cli.js:11:59523)\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:51:7694)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-05-14T08:18:22.431Z"},{"error":"SyntaxError: JSON Parse error: Unexpected identifier \"Please\"\n at <parse> (:0)\n at parse (unknown)\n at Mzq (/$bunfs/root/src/entrypoints/cli.js:175:10088)\n at O (/$bunfs/root/src/entrypoints/cli.js:131:18457)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:177:1430)\n at W4H (/$bunfs/root/src/entrypoints/cli.js:6541:601)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-05-14T08:18:22.432Z"},{"error":"AxiosError: Request failed with status code 401\n at hr (/$bunfs/root/src/entrypoints/cli.js:116:1194)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:121:12716)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:865:50)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-05-14T08:18:44.550Z"},{"error":"Error: Failed to delete keychain entry: security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n at PFq (/$bunfs/root/src/entrypoints/cli.js:245:289181)\n at async M$9 (/$bunfs/root/src/entrypoints/cli.js:401:898)\n at async RH8 (/$bunfs/root/src/entrypoints/cli.js:401:796)\n at async GJ_ (/$bunfs/root/src/entrypoints/cli.js:2638:2388)\n at async _LH (/$bunfs/root/src/entrypoints/cli.js:2664:6149)\n at async <anonymous> (/$bunfs/root/src/entrypoints/cli.js:2689:3468)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-05-14T08:18:44.617Z"},{"error":"AxiosError: Request failed with status code 401\n at hr…
Note: Content was truncated.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗