Skip to content

Commit 7fa10cd

Browse files
7418claude
andcommitted
fix: macOS Node.js install fallback when Homebrew is unavailable, bump v0.17.6
Problem: - Install wizard on macOS failed with "Homebrew not found" when user didn't have Homebrew installed, blocking Claude Code installation entirely Fix (electron/main.ts): - Add fallback: when Homebrew is not found, download official Node.js v22.12.0 binary tarball from nodejs.org and extract to ~/.codepilot/node/ - No Homebrew or sudo required — curl + tar only - Detects architecture (arm64/x64) via process.arch - Add ~/.codepilot/node/bin to getExpandedShellPath() so the downloaded Node.js is found by subsequent install steps and server launcher Install flow now: Homebrew found → brew install node (existing) Homebrew missing → download tarball to ~/.codepilot/node/ (new) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 132fdeb commit 7fa10cd

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

electron/main.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function getExpandedShellPath(): string {
199199
return [...new Set(allParts)].join(sep);
200200
} else {
201201
const basePath = `/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin`;
202-
const raw = `${basePath}:${home}/.npm-global/bin:${home}/.local/bin:${home}/.claude/bin:${shellPath}`;
202+
const raw = `${basePath}:${home}/.npm-global/bin:${home}/.local/bin:${home}/.claude/bin:${home}/.codepilot/node/bin:${shellPath}`;
203203
const allParts = raw.split(':').filter(Boolean);
204204
return [...new Set(allParts)].join(':');
205205
}
@@ -528,17 +528,24 @@ app.whenReady().then(async () => {
528528
let args: string[];
529529

530530
if (isMac) {
531-
// Try Homebrew
531+
// Try Homebrew first, fallback to official tarball download
532532
const brewPaths = ['/opt/homebrew/bin/brew', '/usr/local/bin/brew'];
533533
const brewPath = brewPaths.find(p => fs.existsSync(p));
534-
if (!brewPath) {
535-
addLog('Homebrew not found. Cannot auto-install Node.js on macOS without Homebrew.');
536-
resolve(false);
537-
return;
534+
if (brewPath) {
535+
cmd = brewPath;
536+
args = ['install', 'node'];
537+
addLog(`Running: ${brewPath} install node`);
538+
} else {
539+
// Fallback: download official Node.js binary tarball (no Homebrew/sudo needed)
540+
const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
541+
const nodeVersion = 'v22.12.0';
542+
const nodeDir = path.join(home, '.codepilot', 'node');
543+
const tarballUrl = `https://nodejs.org/dist/${nodeVersion}/node-${nodeVersion}-darwin-${arch}.tar.gz`;
544+
addLog(`Homebrew not found. Downloading Node.js ${nodeVersion} from nodejs.org...`);
545+
addLog(`Architecture: ${arch}, Target: ${nodeDir}`);
546+
cmd = 'sh';
547+
args = ['-c', `mkdir -p "${nodeDir}" && curl -fsSL "${tarballUrl}" | tar xz --strip-components=1 -C "${nodeDir}"`];
538548
}
539-
cmd = brewPath;
540-
args = ['install', 'node'];
541-
addLog(`Running: ${brewPath} install node`);
542549
} else if (isWin) {
543550
cmd = 'winget';
544551
args = ['install', '-e', '--id', 'OpenJS.NodeJS.LTS', '--accept-source-agreements', '--accept-package-agreements'];

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codepilot",
3-
"version": "0.17.5",
3+
"version": "0.17.6",
44
"private": true,
55
"author": {
66
"name": "op7418",

0 commit comments

Comments
 (0)