[BUG] Claude Code 2.1.144 binary crashes immediately when spawned from VS Code (any mode), works fine from Terminal.app
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 Claude Code native binary (v2.1.144, darwin-arm64) crashes immediately with exit code 1 and the message "An unknown error occurred (Unexpected)" whenever it is spawned from within VS Code — whether by the extension panel, the integrated terminal, or via script(1) inside the integrated terminal. The crash happens ~8ms after spawn, which is far too fast to be a network call; the binary is dying during initialization.
The exact same binary (same path, same OAuth tokens, same project folder) runs perfectly when invoked from Apple Terminal.app. The only variable is the parent process tree.
I have extensively tested and ruled out: corrupted bundled binary, account/auth issues, network/region issues, VS Code-injected environment variables (clean env via env -i still fails), and TTY/PTY differences (forced new PTY via script -q /dev/null still fails). The crash appears tied to the VS Code Electron process tree itself.
What Should Happen?
The binary should start successfully and respond to user input (or print the version string for claude --version), regardless of whether the parent process is VS Code's terminal/extension host or Apple Terminal.app. Currently it only works when the parent is Terminal.app.
Error Messages/Logs
Extension output logs (from "View output logs" in panel):
2026-05-19 09:33:05.934 [info] Spawning Claude with SDK query function - cwd: /Users/<user>/Documents/<project>, permission mode: default, version: 2.1.144, /Users/<user>/.vscode/extensions/anthropic.claude-code-2.1.144-darwin-arm64/resources/native-binary/claude, resume: undefined
2026-05-19 09:33:05.942 [info] From claude: error: An unknown error occurred (Unexpected)
2026-05-19 09:33:05.947 [info] Closing Claude on channel: ly2ecrb11pk
2026-05-19 09:33:05.947 [error] Error spawning Claude: Error: Claude Code process exited with code 1
2026-05-19 09:33:05.947 [error] Failed to load config cache: Error: Claude Code process exited with code 1
2026-05-19 09:33:05.948 [error] Error processing client request: Error: Claude Code process exited with code 1
Running `claude` directly in VS Code integrated terminal:
% claude
error: An unknown error occurred (Unexpected)
Same error with clean environment:
% env -i HOME="$HOME" PATH="$HOME/.local/bin:/usr/bin:/bin" TERM="$TERM" claude --version
error: An unknown error occurred (Unexpected)
Same error with forced new PTY via script:
% script -q /dev/null claude
error: An unknown error occurred (Unexpected)
Steps to Reproduce
- Install Claude Code CLI 2.1.144 via
curl -fsSL https://claude.ai/install.sh | bash - Install VS Code (from code.visualstudio.com) with extension anthropic.claude-code-2.1.144-darwin-arm64
- Open any project folder in VS Code
- Click Claude Code panel (✶ icon) → "+ New session" → send any message
- Observe red error banner: "Error: Claude Code process exited with code 1"
- Open VS Code integrated terminal (Ctrl+
), runclaude` - Same crash:
error: An unknown error occurred (Unexpected) - Open Apple Terminal.app, cd to same project, run
claude→ works perfectly
Verification that the binary itself is healthy (in Terminal.app):
claude --version→ prints "2.1.144 (Claude Code)"claude→ opens normally/doctorinside Claude → all green, OAuth tokens present, search OK
Verification that the crash is parent-process-specific (in VS Code integrated terminal):
env -i HOME=$HOME PATH=$HOME/.local/bin:/usr/bin:/bin TERM=$TERM claude --version→ failsscript -q /dev/null claude→ fails
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.144 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Environment Details
- VS Code: Downloaded from code.visualstudio.com (not Homebrew, not MAS), version 1.120.0
- VS Code extension: anthropic.claude-code-2.1.144-darwin-arm64
- Claude Code CLI standalone: 2.1.144 (commit 32281b6b930f)
- Account: Claude Max subscription (Opus 4.7, 1M context)
- Shell: zsh (default macOS)
- Hardware: Apple Silicon iMac
Diagnostic Summary — what I ruled out
| Hypothesis | Test | Result |
|---|---|---|
| Bundled binary broken | Replaced with symlink to standalone CLI (same version, /doctor clean) | Still crashes |
| VS Code env vars | env -i with minimal HOME/PATH/TERM | Still crashes |
| TTY/PTY differences | script -q /dev/null for fresh PTY | Still crashes |
| Project config | Same folder works in Terminal.app | Not the cause |
| OAuth/auth | /doctor clean, tokens refresh OK | Not the cause |
| Account/subscription | Claude Max active, Opus 4.7 available | Not the cause |
| Network/region | claude.ai accessible, OAuth works | Not the cause |
The only remaining variable is the parent process tree: anything whose ancestry traces to VS Code's Electron process fails; Apple Terminal.app succeeds.
VS Code env vars present (none of the usual suspects)
TERM_PROGRAM=vscode
TERM_PROGRAM_VERSION=1.120.0
VSCODE_GIT_ASKPASS_*=...
VSCODE_GIT_IPC_HANDLE=/var/folders/...
VSCODE_INJECTION=1
VSCODE_PROFILE_INITIALIZED=1
VSCODE_PYTHON_AUTOACTIVATE_GUARD=1
__CFBundleIdentifier=com.microsoft.VSCode
Notably ELECTRON_RUN_AS_NODE and NODE_OPTIONS are NOT set. Removing all VS Code env vars via env -i does not resolve the crash.
Possibly related
Issue #53211 reports a very similar crash signature on Antigravity, also when binary is spawned by an IDE host.
Requests
- Could the binary perform process-tree introspection or hardened-runtime checks at startup that fail when the parent is an Electron app?
- Are there specific file-descriptor, process-group, or session-leader expectations that differ between Terminal.app and a node-pty-spawned shell?
- Could a verbose-logging environment variable (e.g. CLAUDE_DEBUG=1) be exposed so users can produce more detailed crash logs than the generic "An unknown error occurred (Unexpected)"?
Happy to test debug builds, patches, or run additional diagnostics. The current workaround (Terminal.app + /ide to connect to VS Code) works but loses the in-IDE experience.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗