[BUG] cwd bug (b3 function) - spaces in directory path names

Resolved 💬 3 comments Opened Mar 12, 2026 by MnkyPwz Closed Apr 13, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The b3 function that sets the internal cwd uses path.resolve and fs.realpathSync — those handle spaces fine. The crash comes from Claude Code's shell snapshot restore mechanism — when it spawns a new Bash tool call, it sources a snapshot file and does an eval 'cd "path" && command'. The quoting breaks somewhere in the snapshot → eval → cd chain when the path contains spaces.

What Should Happen?

When Claude Code resets the shell working directory after a Bash tool call, it should properly quote/escape paths containing spaces. The cd command should use either cd "/path/with spaces/" or cd /path/with\ spaces/.

Error Messages/Logs

zsh:cd:1: no such file or directory:
  Documents/com~apple~CloudDocs/fetgi/it-pace/rellis/netter/witness
  Documents/com~apple~CloudDocs/fetgi/it-pace/rellis/netter/witness

  Pane is dead (status 1)

  The path /Users/heartfelt/Library/Mobile Documents/com~apple~CloudDocs/... splits
  on the space after Mobile. The shell receives two arguments to cd and exits
   with status 1, killing the session.

Steps to Reproduce

  1. Create or use a project directory under a path containing spaces (e.g.,

iCloud's ~/Library/Mobile Documents/com~apple~CloudDocs/)

  1. Launch Claude Code in a tmux session pointed at that directory
  2. Run Bash tool calls that trigger a cwd reset (the Shell cwd was reset to

... message)

  1. The session crashes intermittently when Claude Code sends an unquoted cd

to the shell

Minimal repro:
mkdir -p "/tmp/path with spaces/project"
cd "/tmp/path with spaces/project"
git init
claude --dangerously-skip-permissions
# Then run Bash tool calls that change directories — eventually the cwd
reset will crash the shell

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

v2.1.74.

Claude Code Version

2.1.74 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

  • Intermittent: Not every Bash tool call triggers the crash. It happens

when Claude Code decides the shell cwd needs resetting (typically after a
command changes directories or reports a different cwd).

  • Common with iCloud: macOS users storing projects under iCloud sync get

paths like ~/Library/Mobile Documents/com~apple~CloudDocs/... — the space
in Mobile Documents triggers this bug.

  • Fatal in automation: When running Claude Code as autonomous agents in

tmux sessions (e.g., multi-agent orchestration), this crash kills agent
sessions silently. The tmux pane shows Pane is dead (status 1) with the
unquoted cd error as the last output.

  • Binary analysis: The internal b3 cwd-setter function uses Node.js

path.resolve/fs.realpathSync which handle spaces correctly. The crash
occurs in the shell command execution layer — likely in the snapshot
restore mechanism (source snapshot.sh && eval 'cd ... && command') where
the path escaping is lost during the eval chain.

  • Workaround: Use project paths without spaces, or accept intermittent

crashes and rely on external health monitoring to restart dead sessions.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗