Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/claude_agent_sdk/_internal/transport/subprocess_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ def __init__(
self._write_lock: anyio.Lock = anyio.Lock()

def _find_cli(self) -> str:
"""Find Claude Code CLI binary."""
# First, check for bundled CLI
bundled_cli = self._find_bundled_cli()
if bundled_cli:
return bundled_cli
"""Find Claude Code CLI binary.

# Fall back to system-wide search
Searches in priority order:
1. System-wide PATH (allows users to override bundled binary)
2. Common installation locations
3. Bundled CLI (fallback)
"""
# First, check for system-wide CLI (PATH and common locations)
if cli := shutil.which("claude"):
return cli

Expand All @@ -102,6 +103,11 @@ def _find_cli(self) -> str:
if path.exists() and path.is_file():
return str(path)

# Fall back to bundled CLI if no system-wide installation found
bundled_cli = self._find_bundled_cli()
if bundled_cli:
return bundled_cli

raise CLINotFoundError(
"Claude Code not found. Install with:\n"
" npm install -g @anthropic-ai/claude-code\n"
Expand Down