Skip to content

Commit aca6173

Browse files
committed
fix(ai): add Homebrew + Linuxbrew fallbacks for Claude CLI detection
Apple Silicon Macs running `brew install --cask claude-code` land the binary at /opt/homebrew/bin/claude, which we weren't checking. On macOS, when Phoenix is launched from Finder/Dock the inherited PATH is the minimal /usr/bin:/bin:/usr/sbin:/sbin so `which claude` misses anything in shell-managed dirs — making the fallback list the only detection path that works. Also reorder so the docs-recommended installs (~/.local/bin from install.sh, /usr/local/bin) come first and alternative installs (Homebrew, Linuxbrew) come last.
1 parent 6f582ad commit aca6173

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src-node/claude-code-agent.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,21 @@ function _findGlobalClaudeCliWin() {
221221
* Find the user's globally installed Claude CLI on macOS/Linux.
222222
*/
223223
function _findGlobalClaudeCliLinuxMac() {
224+
const home = process.env.HOME || "";
225+
// The fallback list matters most when Phoenix is launched from
226+
// Finder/Dock on macOS — that PATH is the minimal
227+
// `/usr/bin:/bin:/usr/sbin:/sbin`, so `which claude` won't see
228+
// anything in the user's shell-managed dirs. Order is by likelihood:
229+
// primary docs-recommended installs first, alternatives last.
224230
const locations = [
225-
"/usr/local/bin/claude",
226-
"/usr/bin/claude",
227-
(process.env.HOME || "") + "/.local/bin/claude",
228-
(process.env.HOME || "") + "/.nvm/versions/node/" +
231+
home + "/.local/bin/claude", // claude.ai/install.sh (default)
232+
"/usr/local/bin/claude", // System-wide install / Intel Mac Homebrew
233+
"/usr/bin/claude", // Distro package
234+
home + "/.nvm/versions/node/" +
229235
(process.version.startsWith("v") ? process.version : "v" + process.version) +
230-
"/bin/claude"
236+
"/bin/claude", // npm global via nvm
237+
"/opt/homebrew/bin/claude", // Homebrew on Apple Silicon
238+
"/home/linuxbrew/.linuxbrew/bin/claude" // Linuxbrew
231239
];
232240

233241
// Try 'which -a' first to find all claude binaries, filtering out node_modules

0 commit comments

Comments
 (0)