mirror of https://github.com/garrytan/gstack.git
fix: resolve claude symlinks + check Conductor bundled binary
posix_spawn fails on symlinks in compiled bun binaries. Now: - Checks Conductor app's bundled binary first (not a symlink) - Scans ~/.local/share/claude/versions/ for direct versioned binaries - Uses fs.realpathSync() to resolve symlinks before spawning Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c795e498c1
commit
24e1417aad
|
|
@ -142,13 +142,24 @@ function findBrowseBin(): string {
|
||||||
const BROWSE_BIN = findBrowseBin();
|
const BROWSE_BIN = findBrowseBin();
|
||||||
|
|
||||||
function findClaudeBin(): string | null {
|
function findClaudeBin(): string | null {
|
||||||
|
const home = process.env.HOME || '';
|
||||||
const candidates = [
|
const candidates = [
|
||||||
path.join(process.env.HOME || '', '.local', 'bin', 'claude'),
|
// Conductor app bundled binary (not a symlink — works reliably)
|
||||||
path.join(process.env.HOME || '', '.local', 'share', 'claude', 'versions', 'latest'),
|
path.join(home, 'Library', 'Application Support', 'com.conductor.app', 'bin', 'claude'),
|
||||||
|
// Direct versioned binary (not a symlink)
|
||||||
|
...(() => {
|
||||||
|
try {
|
||||||
|
const versionsDir = path.join(home, '.local', 'share', 'claude', 'versions');
|
||||||
|
const entries = fs.readdirSync(versionsDir).filter(e => /^\d/.test(e)).sort().reverse();
|
||||||
|
return entries.map(e => path.join(versionsDir, e));
|
||||||
|
} catch { return []; }
|
||||||
|
})(),
|
||||||
|
// Standard install (symlink — resolve it)
|
||||||
|
path.join(home, '.local', 'bin', 'claude'),
|
||||||
'/usr/local/bin/claude',
|
'/usr/local/bin/claude',
|
||||||
'/opt/homebrew/bin/claude',
|
'/opt/homebrew/bin/claude',
|
||||||
];
|
];
|
||||||
// Also check if 'claude' is in current PATH (works when spawned from shell)
|
// Also check if 'claude' is in current PATH
|
||||||
try {
|
try {
|
||||||
const proc = Bun.spawnSync(['which', 'claude'], { stdout: 'pipe', stderr: 'pipe', timeout: 2000 });
|
const proc = Bun.spawnSync(['which', 'claude'], { stdout: 'pipe', stderr: 'pipe', timeout: 2000 });
|
||||||
if (proc.exitCode === 0) {
|
if (proc.exitCode === 0) {
|
||||||
|
|
@ -157,7 +168,11 @@ function findClaudeBin(): string | null {
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
for (const c of candidates) {
|
for (const c of candidates) {
|
||||||
try { if (fs.existsSync(c)) return c; } catch {}
|
try {
|
||||||
|
if (!fs.existsSync(c)) continue;
|
||||||
|
// Resolve symlinks — posix_spawn can fail on symlinks in compiled bun binaries
|
||||||
|
return fs.realpathSync(c);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue