-
Notifications
You must be signed in to change notification settings - Fork 557
fix: broaden Claude CLI discovery paths #433
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { describe, it } from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
|
|
||
| import { getClaudeCandidatePathsFor, getExtraPathDirsFor } from '../../lib/platform'; | ||
|
|
||
| describe('Claude path discovery helpers', () => { | ||
| it('darwin search dirs include pnpm, yarn, and claude local compatibility paths', () => { | ||
| const home = '/Users/tester'; | ||
| const dirs = getExtraPathDirsFor('darwin', home, { | ||
| PNPM_HOME: '/Users/tester/Library/pnpm', | ||
| } as unknown as NodeJS.ProcessEnv); | ||
|
|
||
| assert.ok(dirs.includes('/Users/tester/Library/pnpm')); | ||
| assert.ok(dirs.includes('/Users/tester/.claude/local')); | ||
| assert.ok(dirs.includes('/Users/tester/.yarn/bin')); | ||
| }); | ||
|
Comment on lines
+6
to
+16
|
||
|
|
||
| it('darwin candidates include executable paths for pnpm and claude local wrappers', () => { | ||
| const home = '/Users/tester'; | ||
| const candidates = getClaudeCandidatePathsFor('darwin', home, { | ||
| PNPM_HOME: '/Users/tester/Library/pnpm', | ||
| } as unknown as NodeJS.ProcessEnv); | ||
|
|
||
| assert.ok(candidates.includes('/Users/tester/Library/pnpm/claude')); | ||
| assert.ok(candidates.includes('/Users/tester/.claude/local/claude')); | ||
| assert.ok( | ||
| candidates.indexOf('/opt/homebrew/bin/claude') < candidates.indexOf('/Users/tester/Library/pnpm/claude'), | ||
| 'homebrew candidates should stay ahead of npm-family shims', | ||
| ); | ||
| assert.ok( | ||
| candidates.indexOf('/Users/tester/.claude/local/claude') < candidates.indexOf('/Users/tester/Library/pnpm/claude'), | ||
| 'native compatibility wrappers should stay ahead of pnpm shims', | ||
| ); | ||
| }); | ||
|
|
||
| it('win32 search dirs include pnpm and claude local compatibility paths', () => { | ||
| const home = 'C:\\Users\\tester'; | ||
| const dirs = getExtraPathDirsFor('win32', home, { | ||
| APPDATA: 'C:\\Users\\tester\\AppData\\Roaming', | ||
| LOCALAPPDATA: 'C:\\Users\\tester\\AppData\\Local', | ||
| PNPM_HOME: 'C:\\Users\\tester\\AppData\\Local\\pnpm', | ||
| } as unknown as NodeJS.ProcessEnv); | ||
|
|
||
| assert.ok(dirs.includes('C:\\Users\\tester\\AppData\\Local\\pnpm')); | ||
| assert.ok(dirs.includes('C:\\Users\\tester\\.claude\\local')); | ||
| }); | ||
|
|
||
| it('win32 candidates include pnpm cmd wrappers', () => { | ||
| const home = 'C:\\Users\\tester'; | ||
| const candidates = getClaudeCandidatePathsFor('win32', home, { | ||
| APPDATA: 'C:\\Users\\tester\\AppData\\Roaming', | ||
| LOCALAPPDATA: 'C:\\Users\\tester\\AppData\\Local', | ||
| PNPM_HOME: 'C:\\Users\\tester\\AppData\\Local\\pnpm', | ||
| } as unknown as NodeJS.ProcessEnv); | ||
|
|
||
| assert.ok(candidates.includes('C:\\Users\\tester\\AppData\\Local\\pnpm\\claude.cmd')); | ||
| assert.ok(candidates.includes('C:\\Users\\tester\\.claude\\local\\claude.cmd')); | ||
| assert.ok( | ||
| candidates.indexOf('C:\\Users\\tester\\.claude\\local\\claude.cmd') < | ||
| candidates.indexOf('C:\\Users\\tester\\AppData\\Local\\pnpm\\claude.cmd'), | ||
| 'native compatibility wrappers should stay ahead of pnpm shims on Windows', | ||
| ); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
claudeSearchDirsordering for non-Windows currently places npm-family bins (e.g.~/.npm-global/bin, yarn/pnpm) before Homebrew directories (/opt/homebrew/bin,/usr/local/bin). Sinceprimaryis derived from the first successfulcandidatePathsprobe, this can prefer an npm shim even when a Homebrew install exists, contradicting the comment about priority. ReorderclaudeSearchDirsso homebrew directories are checked before npm-family bins.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 1dfc6e7. The Electron-side detection list now uses the same priority shape as the shared helper: native/compat wrappers first, then bun/Homebrew, then npm-family bins.