File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments