claude-code - 💡(How to fix) Fix [BUG] Claude Code 2.1.144 binary crashes immediately when spawned from VS Code (any mode), works fine from Terminal.app [1 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#60436Fetched 2026-05-20 03:58:38
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Error Message

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)

Fix Action

Fix / Workaround

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.

Code Example

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)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

  1. Install Claude Code CLI 2.1.144 via curl -fsSL https://claude.ai/install.sh | bash
  2. Install VS Code (from code.visualstudio.com) with extension anthropic.claude-code-2.1.144-darwin-arm64
  3. Open any project folder in VS Code
  4. Click Claude Code panel (✶ icon) → "+ New session" → send any message
  5. Observe red error banner: "Error: Claude Code process exited with code 1"
  6. Open VS Code integrated terminal (Ctrl+), run claude`
  7. Same crash: error: An unknown error occurred (Unexpected)
  8. 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
  • /doctor inside 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 → fails
  • script -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

HypothesisTestResult
Bundled binary brokenReplaced with symlink to standalone CLI (same version, /doctor clean)Still crashes
VS Code env varsenv -i with minimal HOME/PATH/TERMStill crashes
TTY/PTY differencesscript -q /dev/null for fresh PTYStill crashes
Project configSame folder works in Terminal.appNot the cause
OAuth/auth/doctor clean, tokens refresh OKNot the cause
Account/subscriptionClaude Max active, Opus 4.7 availableNot the cause
Network/regionclaude.ai accessible, OAuth worksNot 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

  1. Could the binary perform process-tree introspection or hardened-runtime checks at startup that fail when the parent is an Electron app?
  2. Are there specific file-descriptor, process-group, or session-leader expectations that differ between Terminal.app and a node-pty-spawned shell?
  3. 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.

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

claude-code - 💡(How to fix) Fix [BUG] Claude Code 2.1.144 binary crashes immediately when spawned from VS Code (any mode), works fine from Terminal.app [1 comments, 2 participants]