-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: Update outdated Claude Code CLI install instructions #1635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6827451
9597ee1
b4cc067
f6eb5ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,10 @@ | |
| * | ||
| */ | ||
|
|
||
| import { execSync } from 'child_process'; | ||
| import { execSync, execFileSync } from 'child_process'; | ||
| import { existsSync } from 'fs'; | ||
| import { join, dirname } from 'path'; | ||
| import { homedir } from 'os'; | ||
| import { createClaudeCode } from 'ai-sdk-provider-claude-code'; | ||
| import { | ||
| getClaudeCodeSettingsForCommand, | ||
|
|
@@ -82,11 +85,39 @@ export class ClaudeCodeProvider extends BaseAIProvider { | |
| execSync('claude --version', { stdio: 'pipe', timeout: 1000 }); | ||
| _claudeCliAvailable = true; | ||
| } catch (error) { | ||
| _claudeCliAvailable = false; | ||
| log( | ||
| 'warn', | ||
| 'Claude Code CLI not detected. Install it with: npm install -g @anthropic-ai/claude-code' | ||
| ); | ||
| // PATH-based lookup failed - check common install locations | ||
| // The native binary may be installed outside the current PATH | ||
| // (e.g. when running as an MCP server with a minimal environment) | ||
| const home = homedir(); | ||
| const commonPaths = [ | ||
| join(home, '.local', 'bin', 'claude'), | ||
| join(home, '.bun', 'bin', 'claude'), | ||
| '/usr/local/bin/claude' | ||
| ]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing Homebrew Apple Silicon path in fallback detectionMedium Severity The |
||
| const found = commonPaths.find((p) => existsSync(p)); | ||
| if (found) { | ||
| try { | ||
| execFileSync(found, ['--version'], { | ||
| stdio: 'pipe', | ||
| timeout: 1000 | ||
| }); | ||
| // Add the binary's directory to PATH so the SDK can find it | ||
| const binDir = dirname(found); | ||
| process.env.PATH = `${binDir}${process.platform === 'win32' ? ';' : ':'}${process.env.PATH || ''}`; | ||
| _claudeCliAvailable = true; | ||
| } catch { | ||
| _claudeCliAvailable = false; | ||
| } | ||
| } else { | ||
| _claudeCliAvailable = false; | ||
| } | ||
|
|
||
| if (!_claudeCliAvailable) { | ||
| log( | ||
| 'warn', | ||
| 'Claude Code CLI not detected. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started' | ||
| ); | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| } finally { | ||
| _claudeCliChecked = true; | ||
| } | ||
|
|
@@ -147,7 +178,7 @@ export class ClaudeCodeProvider extends BaseAIProvider { | |
| const code = error?.code; | ||
| if (code === 'ENOENT' || /claude/i.test(msg)) { | ||
| const enhancedError = new Error( | ||
| `Claude Code CLI not available. Please install Claude Code CLI first. Original error: ${error.message}` | ||
| `Claude Code CLI not available. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started - Original error: ${error.message}` | ||
| ); | ||
| enhancedError.cause = error; | ||
| this.handleError('Claude Code CLI initialization', enhancedError); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.