[BUG] Bash tool: env vars with spaces in values cause zsh startup errors
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?
Description
When running Claude Code as a VS Code extension, the Bash tool spawns zsh subshells that produce spurious errors before every command. The errors are cosmetic (commands still execute correctly) but noisy.
Error output (appears before every command)
zsh:19: permission denied: /run/current-system/sw
zsh:23: no such file or directory: Support/Code/CachedData/8b640eef5a6c6089c029249d48efa5c99adf7d51
zsh: command not found: 36:ln=35:so=32:pi=33:ex=31:bd=34
zsh: command not found: 46:cd=34
zsh:33: no such file or directory: Support/Code/1.11-main.sock
zsh: command not found: -R
Root cause
VS Code sets environment variables whose values contain spaces:
VSCODE_CODE_CACHE_PATH=/Users/mikael/Library/Application Support/Code/CachedData/...VSCODE_IPC_HOOK=/Users/mikael/Library/Application Support/Code/1.11-main.sock
When the Bash tool generates its shell wrapper/snapshot script, it embeds these env var values without quoting. Zsh then splits on the space — Application Support becomes two tokens — and tries to execute Support/Code/... as a command.
The errors persist even with ZDOTDIR=/tmp HOME=/tmp zsh --no-rcs --no-globalrcs -c 'echo ok', confirming the issue is in the wrapper generated by Claude Code, not in any user startup file.
Environment
- Claude Code version: 2.1.140
- Platform: macOS (darwin arm64)
- Shell: zsh
- VS Code version: 1.11
- Running as: VS Code extension (
CLAUDE_CODE_ENTRYPOINT=claude-vscode)
Expected behavior
Env var values containing spaces should be quoted when embedded in generated shell scripts, so Application Support is not split into separate tokens.
Workaround
No workaround found yet.
What Should Happen?
The VSCode extension should quote the env variable when using them allowing Paths with spaces.
Error Messages/Logs
Steps to Reproduce
Use VSCODE_CODE_CACHE_PATH with a path that contain a space.
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.140
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗