Skip to content

Commit eb1da08

Browse files
committed
Fix Claude CLI symlink resolution issue
1 parent 3c664ce commit eb1da08

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

‎src/cli/detection.ts‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,26 @@ async function fileExists(filePath: string): Promise<boolean> {
4444
await fs.promises.access(filePath, fs.constants.X_OK);
4545
return true;
4646
} catch {
47-
return false;
47+
// Fallback for symlinks (e.g. WSL ~/.local/bin/claude -> versioned path)
48+
// and filesystems where X_OK check is unreliable. Resolve the symlink
49+
// and check the target for existence + executability.
50+
try {
51+
const resolved = await fs.promises.realpath(filePath);
52+
if (resolved !== filePath) {
53+
await fs.promises.access(resolved, fs.constants.X_OK);
54+
return true;
55+
}
56+
} catch {
57+
// Fall through
58+
}
59+
// Last resort: plain existence check. spawn() follows symlinks natively,
60+
// so if the path exists we let the shell decide whether it can execute it.
61+
try {
62+
await fs.promises.access(filePath, fs.constants.F_OK);
63+
return true;
64+
} catch {
65+
return false;
66+
}
4867
}
4968
}
5069

0 commit comments

Comments
 (0)